Netflix Lookup Python Coding Activity
In this activity, you will find information about some of Netflix’s most popular videos.

Starter file
# Modules
import os
import csv
# Prompt user for video lookup
# Set path for CSV file
# Open the file and loop through to search for the video
# If video is found, print title, rating, and user ratings.
# If the video is never found, alert the user
Instructions
- Prompt the user to input the video they are looking for.
- Search through
netflix_ratings.csvto find the user’s video.- If the CSV contains the user’s video, print out the title, what it is rated, and the current user ratings. For example, “Pup Star is rated G with a rating of 82.”
- If the CSV does not contain the user’s video, print out a message telling the user that their video could not be found.
Solution
# Modules
import os
import csv
# Prompt user for video lookup
video = input("What show or movie are you looking for? ")
# Set path for file
csvpath = os.path.join("..", "Resources", "netflix_ratings.csv")
# Bonus
# ------------------------------------------
# Set variable to check if we found the video
found = False
# Open the CSV
with open(csvpath, newline="") as csvfile:
csvreader = csv.reader(csvfile, delimiter=",")
# Loop through to search for the video
for row in csvreader:
if row[0] == video:
print(row[0] + " is rated " + row[1] + " with a rating of " + row[5])
# BONUS: Set variable to confirm we have found the video
found = True
# BONUS: Stop at first results to avoid duplicates
break
# If the video is never found, alert the user
if found is False:
print("Sorry about this, we don't seem to have what you are looking for!")