Write a program that iterates over a dictionary and prints "Bingo!" if length of value is greater than the length of key. Otherwise print "no bingo"


Topic: Write a program that iterates over a dictionary and prints "Bingo!" if length of value is greater than the length of key. Otherwise print "no bingo"

Solution

key_val_map = {"key1": "length1", "key2": "len2", "Hello": "hi", "bingo": "print bingo"}
for key, val in key_val_map.items():
  if len(val) > len(key):
    print("Bingo!")
  else:
    print("no bingo")



List all Python Programs