141k views
4 votes
Write a program that asks the user to enter a city name, and then prints Oh! CITY is a cool spot. Your program should repeat these steps until the user inputs Nope.

Sample Run
Please enter a city name: (Nope to end) San Antonio
Oh! San Antonio is a cool spot.
Please enter a city name: (Nope to end) Los Angeles
Oh! Los Angeles is a cool spot.
Please enter a city name: (Nope to end) Portland
Oh! Portland is a cool spot.
Please enter a city name: (Nope to end) Miami
Oh! Miami is a cool spot.
Please enter a city name: (Nope to end) Nope

1 Answer

5 votes

Answer:

# Ask the user to enter a city name

city = input("Please enter a city name: (Nope to end) ")

# Repeat until the user inputs "Nope"

while city != "Nope":

# Print a message about the city

print("Oh! %s is a cool spot." % city)

# Ask the user for another city name

city = input("Please enter a city name: (Nope to end) ")

User Vkammerer
by
4.7k points