I'm trying to check if a given word by the user is a key in my dictionary but the response always goes to the 'else' part instead.
This is my dic:
mydic = {'Paris':[132,34] 'Rome':[42,35] 'San Remo':[23,66]}
This is the code:
my_input = input('Write a command').lower()
useful_input = my_input.split()
if my_input == 'info':
print("Write 'city' and city name to get the info")
elif their_command == 'city' and phrase:
if phrase in mydic.keys():
print(f"{phrase} city has {mydic.get(phrase)[0]} churches.")
else:
print('Wrong')
So I need to search if the second word (or second and third word) after the word 'city', which is the command, is a key in my dictionary. If it is, I need to return the key's first value in the print statement. With my code, it goes straight to the 'else' and prints 'wrong', so why is this happening?