Plot Generator
by the Brothers Heimberg: Jason & Justin

plotgenerator.py

The two consecutive quoted strings on lines 20–21 behave as if they were one big quoted string. No backslash is necessary, because these lines are within the [square brackets] in lines 11 and 43. Ditto for lines 52–53, 88–89, 100–101.

The choice function that belongs to random returns a randomly selected item of the given list.

Keep pressing return, or control-d to exit.

Bigfoot
rescue(s) a group of American P.O.W.'s
in the middle of Downtown Tokyo (in Japanese with English subtitles).

A hooker with a heart of gold
become(s) immersed in hip-hop culture
with the help of the ghost of Elvis.

America's founding fathers
invade(s) Poland
to save the local synagogue.

From a land where honor and tradition reign, comes the legend of a Samurai who
command(s) a fleet of starships against a horde of insectoid aliens
set to an all-star '80's soundtrack featuring Air Supply, Journey, and Survivor.

Things to try

  1. Change
    print("Keep pressing return, or control-d to exit.")
    
    to
    plat = sys.platform   #type of operating system
    
    if plat.startswith("darwin") or plat.startswith("linux"): #macOS or Linux
        print("Keep pressing return, or control-d to exit.")
    elif plat.startswith("win32"):                            #Microsoft Windows
        print("Keep pressing enter, or control-z enter to exit.")
    else:
        print(f"Unknown platform {plat}")
        sys.exit(1)
    

  2. Make the predicate and modifier agree in number with the subject. Create the following two variables before you create the subjects list, giving them short, uppercase names.
    S = 0   #singular
    P = 1   #plural
    

    Replace each subject with a list containing two items: an S or P and the subject itself. For example, change

    subjects = [
        "A cop who doesn't play by the rules",
        "A single mom",
        "Three naughty nurses",
    
    to
    subjects = [
        [S, "A cop who doesn't play by the rules"],
        [S, "A single mom"],
        [P, "Three naughty nurses"],
    

    Replace each predicate with a list of two predicates, singular and plural. For example, change

    predicates = [
        "fight(s) crime",
        "raises(s) a baby",
        "discover(s) the wonders of self pleasure",
    
    to
    predicates = [
        ["fights crime",                           "fight crime"],
        ["raises a baby",                          "raise a baby"],
        ["discovers the wonders of self pleasure", "discover the wonders of self pleasure"],
    
    or to
    predicates = [
        ["fights crime", "fight crime"],
        ["raises a baby", "raise a baby"],
        [
            "discovers the wonders of self pleasure",
            "discover the wonders of self pleasure"
        ],
    

    Change the while loop to the following.

    while True:
        try:
            _ = input()
        except EOFError:
            sys.exit(1)
    
        s = random.choice(subjects)   #s is a list.  s[0] is a number, s[1] is a string.
        p = random.choice(predicates) #p is a list of two strings.
        print(s[1])
        n = s[0]                      #n is either 0 for singular or 1 for plural.
        print(p[n])                   #Print either p[0] or p[1].
        print(f"{random.choice(modifiers)}.")
    
    Keep pressing return, or control-d to exit.
    
    Bigfoot
    rescues a group of American P.O.W.'s
    in the middle of Downtown Tokyo (in Japanese with English subtitles).
    
    A hooker with a heart of gold
    becomes immersed in hip-hop culture
    with the help of the ghost of Elvis.
    
    America's founding fathers
    invade Poland
    to save the local synagogue.
    
    From a land where honor and tradition reign, comes the legend of a Samurai who
    commands a fleet of starships against a horde of insectoid aliens
    set to an all-star '80's soundtrack featuring Air Supply, Journey, and Survivor.