<filename>Lesson 07.gf/common-app.py
#get() to simply counting in a list/dict. e.g. get (name, 0) -> 0 is default

counts = dict()
randomNames = ["Winston", "Winston", "Grace", "Grace", "Winston"]
for name in randomNames:
    if name not in counts: #if name in counts -> throw an error because there is nothing in the dict
        counts[name] = 0 + 1
    else:
        counts [name] = counts [name] + 1
print(counts)

for name in randomNames:
    counts [name] = counts.get(name, 0) + 1
    #0 is the defacult in the dict, which at the start = 0
    #None is the default value if no value is put
print(counts)
<filename>Lesson 07.gf/common-app.py
#get() to simply counting in a list/dict. e.g. get (name, 0) -> 0 is default

counts = dict()
randomNames = ["Winston", "Winston", "Grace", "Grace", "Winston"]
for name in randomNames:
    if name not in counts: #if name in counts -> throw an error because there is nothing in the dict
        counts[name] = 0 + 1
    else:
        counts [name] = counts [name] + 1
print(counts)

for name in randomNames:
    counts [name] = counts.get(name, 0) + 1
    #0 is the defacult in the dict, which at the start = 0
    #None is the default value if no value is put
print(counts)
#get() to simply counting in a list/dict. e.g. get (name, 0) -> 0 is default #if name in counts -> throw an error because there is nothing in the dict #0 is the defacult in the dict, which at the start = 0 #None is the default value if no value is put