Have you ever use tinyDB or other databases to store value? When there are so many data you have to store, you won’t want to store it with so many
call tinyDB store block. Therefore, the dictionary can be used to help.
What is a dictionary?
Dictionary is a built-in component.
Generally speaking, a dictionary uses a key to call and get the value.
It will return the string
How to use it?
a dictionary uses a key to call and get the value.
What you’ll need:
Same logic as TinyDB, but we use the dictionary this time
The dictionary now acts like tinyDB, can be used for storing almost everything.
How to get the value?
Use the example above,
If the key doesn’t exist, return “not found”.
How to store/ add new value?
Store New value:
It is easy. If you want to replace with the new value, do this
Remember to store the dictionary with tinyDB as well.
Add new value:
Similar to store new value, but it will create a new pair of key and value.
It is really useful when you have to store many values. There are also many features in the dictionary such as return the list of key and value.
If you find a helpful and you have time, leave a like
Ask anything if you have any question, I will try to answer as much as I can.