如果你输入正确的答案,为什么会重复这个?

时间:2018-02-23 04:48:41

标签: python loops

为什么这样重复请帮助!运行此代码后,在输入正确的答案后,代码将继续运行,请帮助

player1pokemonchoice = 'empty'
while player1pokemonchoice != '1' and player1pokemonchoice != '2' and 
player1pokemonchoice != '3' and player1pokemonchoice != '4':
    number = input('''
********PLAYER 1 POKEMON CHOICE********
1. Bulbasaur
HP: between 500 - 1000
ATTACKS:

2. Charmander
HP: between 100 - 500
ATTACKS:

3. Squirtle
HP: between 250 - 750
ATTACKS:

4. Pikachu
HP: between 100 - 600
ATTACKS:
''')
    if player1pokemonchoice == '1':
        print ('TEST')
    elif player1pokemonchoice == '2':
        print ('TEST')
    elif player1pokemonchoice == '3':
        print ('TEST')
    elif player1pokemonchoice == '4':
        print ('TEST')

1 个答案:

答案 0 :(得分:0)

检查你的变量 - “数字”和“player1pokemonchoice”。 “号码”未被分配“player1pokemonchoice”。