samedi 27 octobre 2018

How to make many paths without overcrowding in Python?

I am creating a text-based game where the user can make many different choices and they all lead to different endings or different choices in the future. I was wondering what the best way to accomplish this is because a bunch of if loops sounds like a dumb idea. In pseudo-code this is what I don't want it to look like but what I want the structure to be.

if player_answer = 'yes':
    print('what is big and red')
    player_answer = input
    if player_answer = 'your mom':
        print('correct, what is small and blue')
    elif player_answer = 'your dad':
        print('wrong, what is small and blue')
    else:
        print('try again')
elif player_answer = 'no':
    print('Try answering yes next time my dude')
else:
    print('leave me alone')

Aucun commentaire:

Enregistrer un commentaire