- 1
Using Dictionary and If together
How to use Dictionary and If Statement together??
1 Antwort
+ 9
Just an example: /Python/
d = {1: 'a', 2: 'b', 3: 'c'}
k = int(input('Key to check: '))
if k in d:
print('Key {0} found in d dictionary. It equals {1}.'.format(k, d[k]))
else:
print("None")