How to use if/else statement in value that is attribute in dictionary of python?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to use if/else statement in value that is attribute in dictionary of python??

Let, dict={"xyz" :"black", "yxz" :"white", "zxy" :"white"} Now how to print name(key) only white using if/else??

20th May 2018, 3:09 AM
Mahesh Ghorsaine
Mahesh Ghorsaine - avatar
1 Answer
+ 2
is this your doubt? for k,v in dict.items(): if k[0] == "z": print(v) o/p : white
20th May 2018, 3:36 AM
Bharath_Teki 🇮🇳
Bharath_Teki 🇮🇳 - avatar