I always have trouble deciding what to watch next, so I wanted to create a useful script that would choose for me.
#what_to_watch.py
#
# Author: Natalie Larsen
#
# Last Edit: 2020-09-04
#
#This script takes movie or show titles input by the user
#and outputs one for the user to watch next.
#Example user input:
#The Princess Bride,,1917,,Monsters, Inc.,,Once Upon a Time... In Hollywood
# If the result isn’t satisfying,
#the user has the option to re-pick.
#
#Required Modules
import random
import argparse
import sys
#Randomly pick a title from a list, and return choice
def pick_title():
= random.choice(user_list)
to_watch print("You should watch:", to_watch)
#Give user the option to re-pick
def new_title():
= input("Do you want us to pick again? (y/n): ")
pick_again #If user wants to re-pick, run pick_title function
if pick_again == "y":
pick_title()
new_title()elif pick_again == "n":
print("Happy viewing!")
#Handle user inputs other than y or n
else:
print("Sorry we didn't get that, please answer y or n.")
new_title()
if __name__ == "__main__":
#Support for --help or -h command-line arguments
= argparse.ArgumentParser(
p = "This script takes a list of movies/shows input by the user \
description (ex. movie1,,movie2,,movie3,,etc.) and returns one to watch.")
= p.parse_args()
args
#Get user input,
#taking into account punctuation in titles
print("Can't decide what to watch? Let us help!")
= input("Enter a list of movies/shows, separating titles with two commas(A,,B):\n")
user_input
#Turn input into list
if ',,' in user_input:
= user_input.split(',,')
user_list print("You input the following choices:", user_list)
#Handle unacceptable user inputs
else:
print("Please enter more than one title, separated by two commas(,,).")
sys.exit()
pick_title() new_title()