Untitled

mail@pastecode.io avatar
unknown
plain_text
9 days ago
1.6 kB
3
Indexable
Never
from mblock import event



RemovedSymbols = ""
questions=["hello","hi","hey","yo","how are you","yes"]
answers=["Hello!","Hi!","Hi!","Yo doe!","Good","Cool"]
symbols=["<",".","!","?",">"]

@event.greenflag
def on_greenflag():
    global RemovedSymbols
    while True:
        answer = sprite.input('Say something!')
        sprite.broadcast_and_wait('RemoveSymbols')
        if sprite.answer in questions:
            print(sprite.answer)
            print(questions)
            print(answers)
            j=0
            while not questions[j] == sprite.answer:
                j=j+1
                print(answers[j]+ " / "+questions[j])

            sprite.say(answers[j], 2)

        else:
            sprite.say('I do not know that word.', 2)
            answer = sprite.input('Could you teach me it?')
            if sprite.answer == 'yes':
                print("R: "+RemovedSymbols)
                questions.append(RemovedSymbols)
                print(questions)
                answer = sprite.input(str('What does ') + str(RemovedSymbols) + str(' mean?'))
                answers.append(sprite.answer)
                print(answers)

            else:
                sprite.say('Oh well...', 2)




@event.received('RemoveSymbols')
def on_received():
    global RemovedSymbols
    i = 0
    RemovedSymbols = ""
    for count in range(len(sprite.answer)):
        if not sprite.answer[i] in symbols:
            RemovedSymbols = (str(RemovedSymbols) + str(sprite.answer[i]))

        i = i + 1


   

Leave a Comment