- 1

Using Dictionary and If together

How to use Dictionary and If Statement together??

13th May 2017, 1:54 PM
Shashank
Shashank - avatar
1 Answer
+ 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")
13th May 2017, 8:13 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar