+ 1
Why this code prints only keys not values.
Age = {"John" : 24, "Mary" : 27, "Sham" : 87} for word in Age: print(word)
3 Answers
+ 6
Because that's how the dict class is designed by default :)
If you want to return the values instead, you can print(Age[word]) or use Age.values() in the for loop.
If you want to return the key-value pairs, you use Age.items()
+ 3
Because this is for in loop
-> it is looping through the indexes, which are exactly the names.
+ 1
thank you Kuba SiekierzyĆski