Dictionaries; for-loops ex39.py


#1

Hi there!
This might be a piece of cake for others, but I’ll accept the humiliation for the sake of understanding. I would like to know the English translation of lines 38 & 43 in ex39.py script. Thanks.

image


#2

Hello @PyBaseLearner_J

abbrev and city are variables.

list(cities.items()) gives the key and value in the dictionary.
(example: {”NY”: ”New York”} )

In the for loop abbrev = key and city = value.
So the print(f”{abbrev} has the city {city} will be:
”NY has the city New York”

I don´t think it´s humiliating to ask.
It’s brave.


#3

Thanks @ulfen69. Your time and help are greatly appreciated.
Have a good one.