How can i stop this Infinite While Loop - Python

Gunnar Þór Magnússon gunnar at magnusson.io
Wed Oct 30 08:29:01 EDT 2019


>   item = input()                                        
>   if item != -1:

If you try this in the REPL, you'll see that 'item' is a string. You're
trying to compare it to an integer, which will always fail.

The cheapest way to fix this is probably:

    if item != '-1':

Best,
G


More information about the Python-list mailing list