22
loading...
This website collects cookies to deliver better user experience
# creating an empty dictionary
dictionary = dict()
print(dictionary)
{}
>>>dictionary['one'] = 'uno'
{'one':'uno'}
.>>> dictionary = {'one': 'uno', 'two': 'dos', 'three': 'tres'}
>>> print(dictionary)
{'one': 'uno', 'three': 'tres', 'two': 'dos'}
>>>print(dictionary['one'])
'uno'
>>>len(dictionary)
3
>>>'one' in dictionary
True
>>> 'uno' in dictionary
False
>>>values = list(dictionary.values())
>>> 'uno' in values
True
word = 'brontosaurus'
d = dict()
for o in word:
if o not in d:
d[0] = 1
else:
d[0] = d[0] + 1
print(d)
# we get {'o':2}