Python Forum
while loop not working-I am using sublime text editor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
while loop not working-I am using sublime text editor
#1
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.
Larz60+ write Feb-06-2023, 02:06 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button

Attached Files

Thumbnail(s)
   
Reply
#2
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 welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply
#3
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".
Reply
#4
   
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.
Reply
#5
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Text conversion to lowercase is not working ineuw 3 473 Jan-16-2024, 02:42 AM
Last Post: ineuw
  Decryption not working if key has same symbol like text Paragoon2 0 319 Nov-11-2023, 09:32 PM
Last Post: Paragoon2
  ANSI not working for change of text colors BliepMonster 10 3,409 Nov-10-2022, 09:28 AM
Last Post: BliepMonster
  Sublime Text Editor not recognizing Python elroberto 5 2,883 Jun-13-2022, 04:00 PM
Last Post: rob101
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,494 Apr-05-2022, 06:18 AM
Last Post: C0D3R
  Skipping line in text without Restarting Loop IdMineThat 4 1,491 Apr-05-2022, 04:23 AM
Last Post: deanhystad
  Music Notation editor; how to build the editor? direction to go? philipbergwerf 1 1,695 Jan-01-2022, 04:56 PM
Last Post: Larz60+
  Code folding in Sublime Text Mondata 2 2,808 Mar-12-2021, 04:16 PM
Last Post: Mondata
  How to link Sublime Text 3 Build system to Python 3.9 Using Windows 10 Fanman001 2 4,612 Mar-04-2021, 03:09 PM
Last Post: martpogs
  Sublime Text TechNitium 4 2,775 Jan-23-2021, 08:41 AM
Last Post: TechNitium

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020