Jump to content


Member Since 08 Mar 2017
Offline Last Active Aug 04 2017 07:43 AM

Posts I've Made

In Topic: Python

09 March 2017 - 08:26 AM

I wanted to test if a key exists in a dictionary before updating the value for the key. I wrote the following code:

if 'key1' in dict.keys():
print "blah"
print "boo"

I think this is not the best way to accomplish this task. Is there a better way to test for a key in the dictionary for python?