+ 1

what's the difference between these

1: one 1 = one 1 == one

5th Jun 2017, 6:49 PM
HASSAN AIT BIHI
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"])
5th Jun 2017, 7:28 PM
Michael Foster
Michael Foster - avatar
+ 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.
5th Jun 2017, 7:15 PM
Michael Foster
Michael Foster - avatar
+ 6
Normally a dictionary is written something like this: myDict = {1:"one", 2:"two",3:"three"}
5th Jun 2017, 7:21 PM
Michael Foster
Michael Foster - avatar
+ 1
I understand the second and the third but I still struggling with the first
5th Jun 2017, 7:18 PM
HASSAN AIT BIHI
+ 1
lets pick up 1:"one" . want this means in this dictionary?
5th Jun 2017, 7:22 PM
HASSAN AIT BIHI