Today was spend playing with dictionaries, lists and nesting those. I found it very do-able but again was thinking too complicated at some point.
Day 9 of my #100DaysOfCode #Python challenge done, played with (nested) dictionaries and lists today. And if you look at my code in GitHub I am not going for cosmetics but pure functionality
— Wouter Kursten (@Magneet_nl) January 12, 2021
Notes
dictionaries
{key: value}
programming_dictionary = {
"Bug": "An error in a program that prevents the program from running as expected.",
"Function": "A piece of code that you can easily call over and over again.",
}
properly use strings for the keys
add key pair:
programming_dictionary["Loop"] = "Doing an action over and over"
create empty or clean dictionary
empty_dictionary = {}
for key in programming_dictionary:
print(key)
print(programming_dictionary[key])
can be nested
nested dictionary: only curly brackets for the 'main dict'
travel_log = {
"France": {"vities_visited":["Paris","Lille"], "total_visits": 12},
"Germany": {"vities_visited":["Berlin","Hamburg"], "total_visits": 5}
}
print(travel_log)
