if语句中的语法错误

时间:2013-06-09 00:43:13

标签: 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

所以这给我带来了一些麻烦。我想从他们输入的内容中添加一个值到之前定义的变量,但它给我一个语法错误。

1 个答案:

答案 0 :(得分:2)

靠近底部的这条线:

added = int(input("How many points would you like to assign?")

您忘了在最后添加第二个右括号。