24 lines
478 B
Python
24 lines
478 B
Python
# Favorite problem instead of favorite language
|
|
|
|
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 counts
|
|
for favorite, count in counts.most_common():
|
|
print(f"{favorite}: {count}")
|