Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #47513

Simple program question.

Newsgroups comp.lang.python
Date 2013-06-09 20:06 -0700
Message-ID <af6709e3-b446-443a-abe1-5f80d0c30387@googlegroups.com> (permalink)
Subject Simple program question.
From eschneider92@comcast.net

Show all headers | View raw


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()

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Simple program question. eschneider92@comcast.net - 2013-06-09 20:06 -0700
  Re: Simple program question. Chris Angelico <rosuav@gmail.com> - 2013-06-10 13:33 +1000
  Re: Simple program question. eschneider92@comcast.net - 2013-06-10 23:47 -0700
  Re: Simple program question. russ.pobox@gmail.com - 2013-06-11 00:25 -0700

csiph-web