6. Dictionaries¶
Type of data key - value
6.1. Definiowanie¶
>>> workers = {1: 'Adam', 3: 'Tomasz', 4: 'Kasia'}
>>> print(workers)
6.2. Checking type¶
>>> type(workers)
<class 'dict'>
6.3. Operations on dictionary¶
Checking length of dictionary
>>> len(workers)
3
Checking element occurrences
>>> 3000 in workers
False
>>> 1 in workers
True
Employee with id 1 exists inside of dictionary
Adding element to the list
>>> workers[15] = "Marek"
>>> print(workers)
>>> print(len(workers))
4
6.4. Exercises¶
Create dictionary with capitols of:
France,
Germany,
Poland,
Czech republic
Get capitol of Uk - in case of not having capitol within dictionary print
"unknown capitolRemove capitol of Czech republic from dicionary,
Hint
Look for the method which is giving you some text in case of not having specific key inside of dict