在Python随机句子生成器中解析时出现意外的EOF

时间:2017-01-02 14:13:51

标签: python random input

我正在运行没有扩展的Python 2.7.12。这是我的代码,我在解析时遇到了意外的EOF。

$ sudo apt-get install docker-engine

如果你能提供帮助,谢谢,是的,如果你想要一些声誉,我会“接受”答案。

1 个答案:

答案 0 :(得分:1)

你的身份已经消失;有正确的缩进(缩写所有列表以提高可见性......):

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