I've been plugging away on the Codecademy python course and I had a solution that worked. However, during the verification process, I added an extra bit of code that would print the current state the for loop is in. When I execute the code, however, it seems to go through one iteration before quitting, which I know is not the case. The following is my code:
def is_prime(x):
if x < 2:
return False
if x == 2:
return True
if x == 3:
return True
else:
for n in range(2,x-1):
if x % n == 0:
print "Current value is %d." %n
return False
return True
How can I make it print a value each "n" value when the number is going through the loop?
print
directly under thefor
loop.