Thursday, 13 August 2015

Day 2 - list and dict

How to find element in list or dict

LIST

d = [2, 'dwa', 45, 'Fanatastic']

print 'dwa' in d # >>>True


DICTIONARY

k = {'Filip': 3556, 'Ola': 5968, 'Liczby': 'ile ciastek'}
print 'Filip' in k                                 # >>>True same as k.keys()
print 3556 in k                                  # >>>False
print 3556 in k.values()                    # >>>True

print ('Ola', 5968) in k.items()          # >>>True

No comments:

Post a Comment