+ 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 Respuesta
+ 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