Code says infinite loop but none are present!


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>

https://www.codecademy.com/courses/python-intermediate-en-rCQKw/0/6?curriculum_id=4f89dab3d788890003000096#

<In what way does your code behave incorrectly? Include ALL error messages.>

ERROR: The program took too long to finish. Check your code for infinite loops and try again.

<What do you expect to happen instead?>

Move on to next task!

```python

def is_prime(x):
test = 2
n = 1
while n == 1:
if x == test:
return True
n = 0
break
else:
if x % test == 0:
return False
n = 0
break
else:
test += 1

print (is_prime(3))
.

<do not remove the three backticks above>

#2

You’ll have to run through the logic for us on this one. break after return always raises an eyebrow. Without formatting we have no way of knowing where your blocks are.


#3

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