Python Forum

Full Version: while loop not working-I am using sublime text editor
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The while loop is not working for the program below. I am using python 3.6 and practicing on sublime text editor:

prompt="\n Please enter the names of the city you have visited in Europe:"
prompt+="\n (Enter 'quit' when you are finished.)"
while True:
	city=input(prompt)
	if city=='quit':
		break
	else:
		print(f"i'd love to go to {city.title()}.")

The out-put is as below:

Please enter the names of the city you have visited in Europe:
(Enter 'quit' when you are finished.)

(I do not understand where to put the value of the city and why it does not run infinitely. It also does not show the last print command). Please see the attached screenshot.
Please post code in bb tags to hold formatting.

Maybe something like this

print('Please enter the name of cities.\nEnter quit when finished')
while True:
    city = input('>> ')
    if city.lower() == 'quit':
        print('Goodbye!')
        break
    else:
        print(f'I\'d love to go to {city.title()}.')
I don't understand your question. Are you wondering how you can enter input for your program? If so, read this:

https://www.simplifiedpython.net/sublime-run-python/

Look for "Taking Input from User".
[attachment=2241]
Thanks for your reply. It is still not working on sublime text editor I am using. To clarify further, please see the attachment which shows the program I am trying to practice. The while loop doesn't show any value.
I have no idea what your question is. What do you mean by "not working"? And what do you mean by not working on sublime text editor? Does it work if you run from a command line?