Anyone can help me with this??? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
4th Sep 2022, 1:26 AM
Philmocoucou
Philmocoucou - avatar
4 Réponses
+ 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
4th Sep 2022, 10:08 AM
A͢J
A͢J - avatar
+ 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())
5th Sep 2022, 6:07 AM
Bob_Li
Bob_Li - avatar
0
What do you need help with?
4th Sep 2022, 3:31 AM
Benjamin Rogers
Benjamin Rogers - avatar
0
Coucou MO You are checking key exist in dictionary or not so 1 exist but 'three' and 4 not
4th Sep 2022, 4:01 AM
A͢J
A͢J - avatar