2016-07-06 9 views
1

私はプログラミングが比較的新しいです。関数外のPython変数構文エラー?

私は最初のプログラムを作成して実行しようとしていましたが、エラーが発生しました。私はライン22のint(raw_input())を削除し、いくつかの調整を加えようとしましたが、私のスキルはそれを解決するためのすべてではありません。 〜

1 Premains = 10 #Remaining points assigned before functions 
2 
3 #Function designed to see user's overall stats and remaining points 
4 
5 def print_skills(): 
6 
7   print "Dexterity:" + dex 
8   print "Strength:" + str 
9   print "IntelligenceL:" + int 
10   print "\nYou have %d remaining" % Premain 
11 
12 #Function called when user selects to edit Dexterity attribute 
13 
14 def dex_skill(): 
15   Dpoints = 0 
16   print "Great you choose Dexterity!" 
17   answer = raw_input("would you like to add or subtract points?\n > ") 
18 
19   if answer == "add": 
20     print "You have: %d points remaining!" % Premains 
21 
22     numb =(int(raw_input("How many points would you like to add?\n > ") 
23 
24     Premains = (numb - Premains) 
25     Dpoints = numb + Dpoints 
26 
27     print "Great! you now have: %d Dexterity points!" 
28 
29   else: 
30     print "You choose subtract." 
31     #Subtract code goes here. Similiar to above. 
32 dex_skill() 

これは、私がここで見つけることができる2個のエラーがあります

File "try.py", line 24 
Premains = (numb - Premains) 
    ^
SyntaxError: invalid syntax 
+3

前の行に2つのかっこがありません。 (外側のブラケットセットもまた不必要で、恐ろしいものを引き起こすでしょう) –

+1

ちょっとした提案:StackOverflowに貼り付けるだけではなく、自分で文法エラーのようなことを見つけようとすると、 – pokemon

答えて

関連する問題