+ 1
what's the difference between these
1: one 1 = one 1 == one
5 Answers
+ 7
1 is the key and "one" is the value.
The key allows you to find a value in your dictionary. You can use anything as a key, doesn't need to be a number e.g.
ages = {"Dave": 24, "Mary": 42, "John": 58}
If you want to know how old Dave is:
print(ages["Dave"])
+ 8
First line looks like a key: value pair from a dictionary, but with missing syntax.
Second line, you are trying to create a variable and assign a value to it. This would give an error, because variables can't start with numbers and the word "one" should be written in quotes to make it a string.
Third line, you are checking if the number 1 is equivalent to the word one, again you'd need quotes around the word "one" for the code to work.
+ 6
Normally a dictionary is written something like this:
myDict = {1:"one", 2:"two",3:"three"}
+ 1
I understand the second and the third but I still struggling with the first
+ 1
lets pick up 1:"one" . want this means in this dictionary?