WAP that takes a value and checks whether the given value is part of given dictionary or not. If it is, it should print the corresponding keys otherwise print an error message.
(python)
Answers
Answered by
5
s = input("input value: ")
my_dict = {
"Hello": "world",
"Learn": "python"
}
keys = list(my_dict.keys())
values = list(my_dict.values())
if s in values:
print(keys[values.index(s)])
else:
print("BEEP BEEP!")
Answered by
5
Answer:
s = input("input value: ")
my_dict = {
"Hello": "world",
"Learn": "python"
}
keys = list(my_dict.keys())
values = list(my_dict.values())
if s in values:
print(keys[values.index(s)])
else:
print("BEEP BEEP!")
Similar questions