Skip to content

Commit 4c3cc1a

Browse files
committed
Equivalent Conditions test determines whether the dictionary contains the keys
1 parent 9f7ce48 commit 4c3cc1a

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

using_dict.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@
1919
for name,address in ab.items():
2020
print('Contact %s at %s' % (name, address))
2121

22-
if 'Guido' in ab:
22+
# "if .. in .." Equivalent to "D.__contains__('key')"
23+
#if 'Guido' in ab:
24+
if ab.__contains__('Guido'):
2325
print('\nGuido\'s address is %s' % ab['Guido'])

0 commit comments

Comments
 (0)