0
Anyone can help me with this???
4 Antworten
+ 2
Coucou MO
In dictionary 'nums' 1, 2 and 3 are keys.
so (key in nums) here 'in' is used to check 'key' exist or not
So 'three', 1 are key which you are checking in dictionary 'nums'
but 'three' not exist in 'nums' so it returns False
But 1 is exist in 'nums' so it returns True
+ 1
Coucou MO
'in' when used for dictionary, checks for keys.
if you want to check for values, use the .values() method:
print("three" in nums.values())
0
What do you need help with?
0
Coucou MO
You are checking key exist in dictionary or not so 1 exist but 'three' and 4 not