How to use Dictionaries in Python - #First steps in Python part 10
Today, I learned a bit more about Python, and I discovered what Dictionaries really are, and how they help a system store AND find information.
basically, with a dictionary I can assign lot's of information into a simple, short name I can easily get.
for exemple:
hamburgers = {"cheeseburger" : ["bread, cheese, ham meat", price, instock],
"x-bacon" : ["bread, bacon, ham meat", price, instock]}
in that little code, I have set up a dictionary (hamburgers) and I have inside two items: cheeseburger and x-bacon, and inside those I have their ingredients, price and how many are in stock (the last 2 being a variable that can change).
If I am running the code and I want to get the information on one of my items, I can just do a
burger = input("What do you want to search")
print(hamburgers.get(burger)
and than it just prints the values of the specific burger I want to find information about.
the reason this is important is that I can compact a lot of info by using a dictionary for a enormous amount of things (like a dictionary customers) and then inside the dictionary I have the individual customers and then inside that their info, so yeah, extremely useful and can make code much easier.
If you want to help me change the world: https://apoia.se/teteusbionic
If you have any question or suggestion on other topics, feel free to comment down below or ask me in Facebook or Instagram!
Visit my Facebook Page in: http://fb.com/teteusbionicoficial
Visit my Instagram: https://www.instagram.com/teteusbionic/
Visit my Website: http://www.teteusbionic.com.br