- Code: Select all
`def is_prime(n):`

k = 3

if (n == 2):

flag = true

elif (n % 2 == 1):

flag = false

else:

while (k*k < n):

if (n % k == 0):

flag = false

break

return flag

n = int(input('Please enter positive integer: '))

for i in range(n):

if (is_prime(i)):

print(i)

The error I'm getting is the following:

- Code: Select all
`Traceback (most recent call last):`

line 22, in <module>

if (is_prime(i)):

line 8, in is_prime

flag = false

NameError: name 'false' is not defined

I'm new to python and have no idea how to debug the code. Can anyone help me out please?