python:if循环查找3个变量之一

时间:2015-09-29 03:55:04

标签: python

我仍然是python的新手,而且我正在编写一个基于文本的冒险,我需要它来运行一个循环,如果有三个东西中的一个被称为if class== 'warrior','mage','ranger'

import time
import random

#min and max
lmin=9
lmax=15
hmin=21
hmax=35
#randome light
lattk=random.randint(lmin,lmax)
#random heavy
hattk=random.randint(hmin,hmax)
#level
lvl=1
#xp
xp=0

playing=1
if playing==1:
    print('Hello user\n What shall i call you?')
    user=str(input(''))
    print('Hello',user,'Welcome to TAP')
    print('To start your adventure please choose a class')
    print('Warrior\nMage\nRanger')
    userClass=str(input(''))
    if userClass=='warrior','mage','ranger':        #<-------------------problem
        print('Ah the',userClass,'a very wise choice')
        print('Now its time to pick a starter weapon\nYou have 3 choices:')
        if userClass=='warrior':
            print('Mace\nSwoard\nAxe')
            weapon=str(input(''))
            if weapon=='mace':
                print('the mace does 14-25 attack dmg')6
            elif weapon=='sword':
                print('The sword does 12-26 damage')
            elif weapon=='axe':
                print('The axe does 16-24')
            else:
                print('Sorry',weapon,'is not a valid weapon')
    else:
        print('Please input a valid class')

0 个答案:

没有答案