if语句中的语法错误

2024-04-28 12:45:19 发布

您现在位置:Python中文网/ 问答频道 /正文

所以我试着为我的类制作一个角色创建器RPG,但是我遇到了一个错误

#import modules
import random
#define variables
Strength = 0
Health = 0
Wisdom = 0
Dexterity = 0
Pool = 30
choice = None
#Welcome the Player
while choice != 0:
    print ("""
    Welcome to teh CharacterCreator program for RPG's
    What would you like to do?
    0 - Quit
    1 - Assign Point to Atrributes
    2 - Remove Points
    3 - Look at point values
       """);

    choice = input("Choice:")
    print()
    # exit

    if choice == "0":
        print("good-bye.")
    elif choice == "1":
         while Pool > 0:
              print(" You have ",Pool," points left.")
              #Ask which atrribute to chose
              print (""" What would you like to assign points to:
                    Dexterity(1)?
                    Strength(2)?
                    Health(3)?
                    Wisdom(4)?""")
              #assign actions
              pick = input("Choice(1-4):")
              if pick == 1:
                  added = int(input("How many points would you like to assign?")
                  Dexterity += added#I want to add the variable from up there but it give me a syntax error
                  Pool -= added

所以这给了我一点麻烦。我想将他们输入的值添加到前面定义的变量中,但这给了我一个语法错误。你知道吗


Tags: toimportyouaddedinputstrengthrpgpoints