summaryrefslogtreecommitdiff
path: root/wk7/lect/favorites.py
blob: 289a17ff13e3e87a57a90e277c264e916f729a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

# DOESN'T WORK BECAUSE WE DON'T HAVE FAVORITES.CSV



import csv

with open("favorites.csv") as file:
    reader = csv.DictReader(file)
    scratch, c, python = 0, 0, 0

    for row in reader:
        favorite = row['language']
        if favorite == "Scratch":
            scratch += 1
        elif favorite == "C":
            c += 1
        elif favorite == "Python":
            python += 1

print("Scratch:", scratch)