I want to print('Doesn't exist') when the input is not a key in dictionary, it looks like its checking every single key in dictionary and prints if its there or not. I would like to ask if its possible to get output only one time if dictionary doesn't' contain input.
number = input('Number: ')
data = {
'1' : 'One',
'2' : 'Two',
'3' : 'Three',
}
number = number.upper()
for a, value in data.items():
if a == number:
print(number, ":", value)
else:
print('Doesnt exist here')
Number: 1
1 : One
Doesnt exist here
Doesnt exist here