<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">from ml_quotes import quotes, authors, originals
import random

# assume you have the following:
# quotes: a list of strings that have been prepared for madlibs
# originals: a list of the original quotes
# authors: a list of the authors of said quotes
#
# A string in quotes looks like this:
# "To &lt;verb&gt; or not to &lt;verb&gt;. That is the &lt;noun&gt;."
#
# The part of speech that needs to be replaced is indicated with &lt; &gt;.
# 
# Write code that randomly picks a quote from the quotes list, prompts the 
# user for all the words needed to complete the quote, and then prints out
# both the original and the new version of the quote, in quotes.

def print_quote(quote, author):
    print("\""+quote+"\" --"+author)

num_quotes = len(quotes)
random_num = 1 #random.randint(0, num_quotes-1)
quote = quotes[random_num]

n_replacements = quote.count("&lt;")

new_quote = ""
for n in list(range(n_replacements)):
    start_index = quote.find("&lt;")
    end_index = quote.find("&gt;")
    new_quote = new_quote + quote[0:start_index]
    prompt = quote[start_index+1:end_index]
    new_word = input("Please give me a "+prompt+": ")
    new_quote = new_quote + new_word
    quote = quote[end_index+1:]

print("the original:")
print_quote(originals[random_num], authors[random_num])
print("your quote:")
print_quote(new_quote, authors[random_num])
</pre></body></html>