I'm trying to iterate through the items in a list:
cities = ['San Francisco', 'Los Angeles', 'Phoenix', 'Las Vegas', 'Dallas', 'Miami', 'Washington DC', 'New York']
in order to create new dictionaries with the city name i.e. Phoenix = {}
.
for city in cities:
city = {}
But instead a dictionary named city
is created:
>>> city
{}
>>> type(city)
<class 'dict'>
No dictionaries with the name of the city are created:
>>> Phoenix
Traceback (most recent call last):
File "<pyshell#122>", line 1, in <module>
Phoenix
NameError: name 'Phoenix' is not defined
What am I doing wrong?