Day 9

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.

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)

 

Comments are closed.