Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
25 lines (17 sloc) 489 Bytes
cities = {'CA': 'San Francisco', 'MI': 'Detroit', 'FL': 'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
def find_city(themap, state):
if state in themap:
return themap[state]
return "Not found."
#ok pay attention!
cities['_find'] = find_city
while True:
print "State? (Enter to quit)",
state = raw_input ("> ")
if not state: break
#important line
city_found = cities['_find'](cities, state)
print city_found
Jump to Line
Something went wrong with that request. Please try again.