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 4 years 1 Answer 792 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