tuple key

Run Settings
LanguagePython
Language Version
Run Command
#Example of using tuples as dictionary keys location_data={ #dictionary ('NY', 'USA'): 1000, ('LA', 'USA'):2000, ('TO', 'Canada'):3000 } #Accessing data using a tuple key print(location_data[('NY', 'USA')]) #Output:1000 #Adding a new entry location_data[('CG','USA')]=26000 #Iterating over the dictionary for location, population in location_data.items(): city, country=location print(f"The population of {city} in {country} is {population}.") def a(): print('apple') return('CG','USA') location_data[a]=10 print(location_data[a()])
Editor Settings
Theme
Key bindings
Full width
Lines