ARTICLE AD BOX
I am working with a dictionary in Python and trying to use the .items() function to get the key-value pairs. I saved the result in a variable l, but when I try to access the first element using l[0], I get a TypeError.
Mycode:
my_dict = {"key1": "value1", "key2": "value2"} l = my_dict.items() # This line causes the error: print(l[0])What I'm looking for: I expected l to act like a list. Why can't I retrieve l[0] directly, and what is the correct way to access a specific item by index from dictionary items?
