Check existence of an item

Question

Check if Apple exists in the dictionary below:

fruits={

“mango”:”yellow”,

“pear”:”green:,

“apple”:”red”,

}

in progress 0
YashikaKhurana 55 years 1 Answer 858 views Master 0

Answer ( 1 )

  1. # Assuming that code returns True if item exists in key and false if not
    fruits={ “mango”:”yellow”, “pear”:”green” ,”apple”:”red”}
    enterKey = input()
    print(enterKey in fruits)

Leave an answer

Browse
Browse