Lesson Number One: Why doesnt the name key need []?


So I have attached a picture of my working code for the exercise. My question is why do the "name" keys not require [] around their values?

example of what I think they should be -- 'name': ['Lloyd']

example of the correct version -- 'name': 'Lloyd'

I thought the dictionary keys required the brackets to hold their values? Why is this case special and completely unexplained? I feel like I paid attention to the lesson and I cannot find why myself.


Hi @trpython ,

The value associated with a key in a dictionary can be of any type. If it is a list, square brackets are needed, but if it is only a single string, they are not needed. The "name" keys in the current dictionary are each associated with a string, and the other keys will each be associated with a list of numbers.


Thank you for your reply, that helps me understand much more. I guess I missed the part where that was explained, I thought they all required brackets around them.


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