dimanche 9 septembre 2018

Python: if condition for an another function result?

i'm very new at Python. Learning "dictionary and hash tables" right now. i'm really need your helps.

Here's my problem:

d = {}
d['a'] = 'alpha'
d['b'] = 'beta'

missing_key = 'x' in d
if missing_key == True:
  print ("The key, you are looking for was not found!")
else:
  print ("The key, you are looking for was successfully found!")


print ("Here are keys in database:")
for k, r in enumerate(d.keys(), start=1)
  print ("Key {}: {}".format(k, r))

that for condition works perfectly. but i cant run that if condition. Where am i doing wrong ? Thanks for your help.

also i'm using "Python 3.6" and "Anaconda Spyder"

Aucun commentaire:

Enregistrer un commentaire