Prime Number Logic In Python