how would I write a code in python that takesinput as five letters (coverts it to lowercase) and prints itscorresponding numbers from a dictionary
input_user= input (‘enter four letters: ‘)
dictionary= {‘a’:2, ‘b’:4, ‘c’: 9, ‘d’: 3, ‘e’:2}
Answer
Please find the code below:::
input_user= input (‘enter four letters: ‘)
dictionary= {‘a’:2, ‘b’:4, ‘c’: 9, ‘d’: 3, ‘e’:2}
for letter in input_user:
if letter in dictionary:
print(“For letter %c number is%d”%(letter,dictionary[letter]))
else:
print(“Letter %c is not in the dictionary”%letter)
output:
OR
OR