Help with function syntax error. [Python 2]


#1

Hey guys, I've been looking for a solution to this issue for quite a while but can't wrap my head around it. Whenever I try to run the program, I expect the functions to run but I get a syntax error for newCharacter(), curveSetup() and printStatistics(). Any help is appreciated, heres an image of the error: http://prntscr.com/cxqr7i

import random
import time
import math

def newCharacter():
 global name
 name = raw_input("Hello there, young adventurer. Whats your name? ") #'raw_input' is needed because we need the value as a string and not a variable.
 time.sleep(1.0)
 print(name+"!")
 time.sleep(1.4)
 print "What an amazing name!"
 time.sleep(2.0)
 print "You are about to be transported to a world of mystery..."
 time.sleep(3.0)
 print ""
 print ""
 print ""
 #gameStart()

def curveSetup():
 global curve #'global curve' is needed so that code outside of the function knows what 'curve' is.
 curve = random.randint(12,45) #curve is needed for the exp needed to reach the next level. curve*lvl = exp needed to reach the next level.
 global lvl
 lvl = 1
 global exp
 exp = 0

def printStatistics():
 global expMax
 expMax = (lvl*curve)
 print "-------------------------------"
 print "       PLAYER STATISTICS       "
 print "-------------------------------"
 print ("Character Name : "+name)
 print ("Character Level: "+str(lvl))
 print ("Character Exp  : "+str(exp)+"/"+str(expMax)

newCharacter()
curveSetup()
printStatistics()

#2

Hi @bitrockstar90909 ,

Syntax errors often result from a mistake that a programmer makes on a line that precedes the one on which the interpreter reports the error. The error was discovered when this line was encountered ...

newCharacter()

Therefore, it would be a good idea for you to carefully check this line for something that may remain unfinished ...

print ("Character Exp  : "+str(exp)+"/"+str(expMax)

#3

Thanks, saw it, forgot a bracket. Works fine and dandy now.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.