O'Reilly logo
  • Longxiang Lyu thinks this is interesting:

6-9. Favorite Places:

From

Cover of Python Crash Course

Note

favorite_places = {'bush': ['boston', 'houston'], 'blare': ['boston'], 'justin': ['beijing', 'hangkang', 'tokyo']}
for name in favorite_places.keys():
message = "\n" + name + "'s favorite cit"
if len(favorite_places[name]) == 1:
message += "y is:"
else:
message += 'ies are:'
print(message)
for city in favorite_places[name]:
print('\t' + city.title())