+ 2
Which Choice Cannot be Used as an Entry?
False 0 {2: 4, 3: 9, 4: 16,} <----- this apparently cannot be used as a dict entry. But running >>>squares = {2: 4, 3: 9, 4: 16,} print(squares) Runs just fine. I'm having issues understanding a lot of this "simple" stuff :( How come the question says that's wrong, but Python's like "it's okay."?
4 Réponses
+ 6
The question in the course is, whether or not you can use this as a key, not if that is a valid dictionary.
{{2: 4, 3: 9, 4: 16,}: "Brian"} should not work.
+ 6
@ James: Let's be precise here. The Key:Value pair is part of a larger object, namely a dictionary. And you cannot use dictionaries as keys in other dictionaries.
+ 2
@ Tobi: Oh okay that makes sense. After defining a Key:Value you cannot use that as a Key itself to define another value... right?
It's taking me way longer than I'd appreciate to understand this stuff, lol.
+ 1
gotcha. i thought it was referring to using that Key:Value set in 1 dictionary alone.
thanks for your time, and responses :) You're the Man Now, Dawg.