08-Use of break to end an infinite while loop.py

Sign up Free. Don't forget to check out our challenges, lessons, solve and learn series and more ...

Code Snippet

while 1:
    print ('Spam')
    answer = input('Press y to end this loop')
    if answer == 'y':
        print ('Fries with that?')
print ('Have a ')
print ('nice day!')

Try it yourself