24 lines
446 B
Python
24 lines
446 B
Python
# Gets a specific count
|
|
|
|
import csv
|
|
|
|
from collections import Counter
|
|
|
|
# Open CSV file
|
|
with open("favorites.csv", "r") as file:
|
|
|
|
# Create DictReader
|
|
reader = csv.DictReader(file)
|
|
|
|
# Counts
|
|
counts = Counter()
|
|
|
|
# Iterate over CSV file, counting favorites
|
|
for row in reader:
|
|
favorite = row["problem"]
|
|
counts[favorite] += 1
|
|
|
|
# Print count
|
|
favorite = input("Favorite: ")
|
|
print(f"{favorite}: {counts[favorite]}")
|