Hi Everyone,

My code (below) returns this error message:

Does your is prime function take exactly one argument (an integer)? Your code threw a "'int' object is not iterable" error._

Please help it my indentation?

def is_prime(x):
for n in x:
while n < x-1:
n = 2
n +=1
if x%n == 0:
return False
return True


You need to create a range like this:
for n in range(2, x):
cause you can't create a loop over an integer like x.
Try this code:
for n in 10:
print n

you'll see the same message.

PS: you have this in your code:
while n<x-1:
n = 2
n +=1

it's look like a potencial infinite loop


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.