jeudi 26 décembre 2019

How to prevent an object from being randomly extracted from a list if it has already been extracted?

Once a movie gets extracted, I want the function not to randomly extract it anymore the next time (since I've alreadt watched it). How do I do this? Thank you!

import random
from typing import List

sad_movies = random.choice(["Sad1", "Sad2", "Sad3"])
happy_movies = random.choice(["Happy1", "Happy2", "Happy3"])


mood = input("How are you feeling today? ").lower().title()

def moodmovie():
    if mood == "Happy":
        print("Since you're feeling " + mood.lower() + ", watching... " + happy_movies + " sounds good")
    elif mood == "Sad":
        print("Since you're feeling " + mood.lower() + ", watching... " + sad_movies + " sounds good")
    else:
        print("Try again. Either you're happy or you're sad. How are you feeling today? ")

print(moodmovie())



Aucun commentaire:

Enregistrer un commentaire