Infinite loop


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/4?curriculum_id=4f89dab3d788890003000096#


I ve made an infinite loop, how do I break it?


choice = raw_input('Enjoying the course? (y/n)')

while choice!='y' or choice!='n':  # Fill in the condition (before the colon)
    choice = raw_input("Sorry, I didn't catch that. Enter again: ")


#2

well, if the user enters something valid, for example y, we get:

while false or true

false or true is true. What other operators do we know that is false when we have false and true?


#3

I understand that this statement is always gonna keep inside the loop cause the or makes it that way. Maybe, I didn't make myself clear about my question.

What i meant is that once in the console within an infinite loop, is there a way to break it from there? I mean directly in the console, I didn't find any pause button for running the code.
Thanks


#4

No, there isn't. Some sites like repl.it have it (not sure how they achieved it), if you where to run on your computer in the command line you could send an interrupt signal. But here isn't such button the lessons

best you can do is reload the page


#5

Thanks:smiley:, that is just what I did.
I wasn't sure it might be some controls. Would be great as improvement.


#6

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