Skip to content Skip to sidebar Skip to footer

Unexpected Eof While Parsing In Python Random Sentence Generator

I am running Python 2.7.12 with no extensions. This is my code, and I am getting an Unexpected EOF while parsing. import random import sys import time print('Welcome to the weird s

Solution 1:

your identation was off; there the correct indentation (abbreviated all your lists to increase visibility...):

import random
import sys
import time
print("Welcome to the weird sentence generator.")
wantto = True
print("Press enter to generate a weird sentence. Press Q to quit.")
while True:
    senttype = random.randint(1,5)
    VERBS = ["dying", ...,"failing to think of examples for this random sentence program"]
    verb = random.choice(VERBS)
    VERBSTWO = ["die",...,"solve"]
    NOUNS = ["pig",...,"pop star"]
    noun = random.choice(NOUNS)
    ADVERBS = ["slowly",...,"poorly"]
    adverb = random.choice(ADVERBS)
    ADJECTIVES = ["fat",...,"dumb"]
    adjective = random.choice(ADJECTIVES)
    adjective2 = random.choice(ADJECTIVES)
    noun2 = random.choice(NOUNS)
    COLOURS = ["blue"...,"chocolate"]
    colour = random.choice(COLOURS)
    verb2 = random.choice(VERBSTWO)
    what = input('waiting for input')
    if senttype == 1:
        print("The",noun,"was",adverb,verb,"in the",adjective,"park, but the", adjective2,colour,noun2,"wanted him to", verb2+".")
    if senttype == 2:
        print("My favourite",noun,"is the",adjective,colour,"one",adverb,verb,"in a",noun2+"!")
    if senttype == 3:
        print("I",verb2,"with a",adjective,noun,"frequently and",adverb+".")
    if senttype == 4:
        print("Although",verb,"is",adjective+", the",noun,"was too",adjective2,"to",verb2,"it.")
    if senttype == 5:
        print("The",adjective,colour,noun,"is good at",verb,"and likes to",adverb,verb2,"every day!")
    if what =="Q" or what == "q":
        break

Post a Comment for "Unexpected Eof While Parsing In Python Random Sentence Generator"