Reuven M. Lerner @lernerpython.com · 19d

Want to create a dict of lists in #Python? You can use defaultdict: from collections import defaultdict places = defaultdict(list) while True: city, country = input('Place: ').split() places[country].append(city) # list is guaranteed print(places)

2 likes 0 replies

?