FreeKB - Python (Scripting) hash has_key
Python (Scripting) - hash has_key

The has_key opertor checks to see if a has contains a key. For example, let's consider a hash named "hash" that contains a key called "foo".

hash = {'foo': 'bar'}


An if else statement can be used to print text identifying if the hash contains a key named foo.

if hash.has_key('foo'):
  print("hash contains a key named foo")
  print("hash does not contain a key named foo")


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter af278 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |