Skip to content

Commit 64eb7d7

Browse files
committed
challenge 13 notes
1 parent 91da848 commit 64eb7d7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

days/04-06 collections/challenge_13.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def get_movies_by_director(data):
1616
with open(data, newline='',encoding='utf8') as csvfile:
1717
reader = csv.DictReader(csvfile)
1818
for row in reader:
19+
#can also use try: ... and except ValueError: continue to ignore rows with bad data
1920
if int(row['title_year'].replace('','0')) >= MIN_MOVIES:
2021
directors[row['director_name']].append(
2122
Movie(row['movie_title'], row['title_year'], row['imdb_score'])
@@ -51,6 +52,12 @@ def print_results(directors):
5152
counter += 1
5253
if counter == 21:
5354
break
55+
56+
#can also use Counter to get top 20 directors
57+
#cnt = Counter()
58+
#for director, movies in directors.items():
59+
#cnt[director] += len(movies)
60+
#cnt.most_common(20)
5461
return
5562

5663

0 commit comments

Comments
 (0)