I think it's better To determine whether a key is in a dictionary | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

I think it's better To determine whether a key is in a dictionary

Example: nums = { 1: "one", 2: "two", 3: "three", } print(1 in nums) print("three" in nums) print(4 not in nums) >>>true >>>false >>>true But we can write: nums = { 1: "one", 2: "two", 3: "three", } print(1 in nums.keyworld) print("three" in nums) print(4 not in nums.keyword) And now: >>>true >>>true >>>true If I were a Python developer I would have added this section to the language.

2nd Apr 2020, 11:11 AM
Mohammed Armin Bagheri
Mohammed Armin Bagheri - avatar
3 ответов
+ 1
u can also try this: print(nums. get(4,"not in nums"))
2nd Apr 2020, 11:35 AM
Oma Falk
Oma Falk - avatar
0
Oh,I got it I didn't know there is an other way To determine whether a key is in a dictionary
2nd Apr 2020, 11:34 AM
Mohammed Armin Bagheri
Mohammed Armin Bagheri - avatar
0
This is a good way to check and print our text. It can check all the characters Thanks a lot💐💐💐👌👍👍👍
2nd Apr 2020, 11:40 AM
Mohammed Armin Bagheri
Mohammed Armin Bagheri - avatar