Simple program question.

eschneider92 at comcast.net eschneider92 at comcast.net
Sun Jun 9 23:06:19 EDT 2013


How do I make it so I only have to type in 'parry' once?

import random
words=['hemisses', 'hestabsyou']
randomizer=random.choice(words)
if input()!=('duck', 'parry'):
    print('try again')
if input()=='duck':
    print(randomizer)
    if randomizer=='hemisses':
        results=['you should have ran', 'you win']
        randomresult=random.choice(results)
        print('do you wanna run or fight?')
        if input()=='fight':
            print(randomresult)
            sys.exit()
    if randomizer=='hestabsyou':
        print('you done fail')
        sys.exit()
words2=['you parry his blow', 'he stabs you right behind the clavicle']
randomizer2=random.choice(words2)
if input()=='parry':
    print(randomizer2)
    if randomizer2=='you parry his blow':
        results2=['you should have run away', 'you wins!']
        randomresult2=random.choice(results2)
        print('do you wanna run or fight?')
        if input()=='fight':
            print(randomresult2)
            sys.exit()
    if randomizer2=='he stabs you right behind the clavicle':
        print('Clavicle stab does 100 damage')
        sys.exit()



More information about the Python-list mailing list