Python Logic For Prime Number