Any help is much appreciated!
My assignment is to write a python program that will first ask the user to input the number of cities they wish to visit. Then the program should allow the user to input this and only this number of cities. If
they input the same city name you should not count that as one of the cities. You only need to consider cities spelled EXACTLY the same way. Do not worry about upper and lowercase characters in city names.
I can't seem to figure out how to limit the user input. My program so far is:
def AskForNumberCities():
print number_of_cities
return AskForNumberCities
number_of_cities = raw_input('How many cities do you wish to visit?')
x = int(number_of_cities);
def AskForCityName():
print city_name
return AskForCityName
city_name = raw_input('Please list all cities you wish to visit.')
while True:
if len(city_name) == x:
print city_name
else:
break
Aucun commentaire:
Enregistrer un commentaire