Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 10, 2020 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/1634d9cd272ec8be632b2266e0cebd58 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/1634d9cd272ec8be632b2266e0cebd58 to your computer and use it in GitHub Desktop.
d=dict([('red',1),('blue',2),('green',3)])
print (d)#Output:{'red': 1, 'blue': 2, 'green': 3}
#Checking whether the particular key is in dictionary or not.
if 'red' in d:
print ("True")#Output:True
if 'yellow' in d:
print ("True")
else:
print ("False") #Output:False
if "yellow" not in d:
print ("True")#Output:True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment