Iterators for Dictionaries


#1

Instructions:

1.
Create your own Python dictionary, my_dict, in the editor to the right with two or three key/value pairs.

Then, print the result of calling the my_dict.items().

My code:

my_dict = {
  "Name": "Slark",
  "Skills": 4
  "Carry": True
}


print(my_dict.items())

Error:

File "python", line 4
    "Carry": True
          ^
SyntaxError: invalid syntax

That’s a lie. There’s no mistake.


#2

I think there is a comma missing at the end of the previous line: “Skills”:4,


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.