Jump to content

im making my first python program. it is a simple point tracking program to keep track of books(points). i haven't gotten to getting it to save data for "profiles" of sorts to a data file. However, my current problem is that after i defined a restart program funtiont(line 4) the print statement in the line after has a syntax error pointing to the "t". Any help is GREATLY appreciated!

 

here is the code:

 

import sysimport osdef restart_program():	"""Restarts the current program.	Note: this function does not return. Any cleanup action (like	saving data) must be done before calling this function."""	python = sys.executable	os.execl(python, python, * sys.argvprint """Welcome to the python, Linux friendly version of the book point tracker ver 1.0"""print "=" * 80#begin functionalitywhile True:	try:		current_points = int(raw_input("please enter current amount of points"))		print "You entered %s points." % current_points	except ValueError:		print "That is not a valid input!"		continue	while True:		try:			add_sub = int(raw_input("Are you adding or subtracting points?0=SUBTRACT 1=ADD"))		except ValueError:			print "That is not a valid input"			continue		if add_sub == 0:			while True:				try:					point_subtract = int(raw_input("how many points are you subtracting?"))					print "you have taken %s points from %s points" % ( point_subtract, current_points)					x = current_points - point_subtract					print "you now have %s points" % x					print "if this number is negative, you don't have enough points! restart the program."					print "=" * 80					restart_program()				except ValueError:					print "That is not a valid input!"					print "=" * 80					restart_program()		elif add_sub == 1:			while True:				try:					point_add = int(raw_input("how many points are you adding?"))					print "You are adding %s points to %s points." %( point_add, current_points)					y = current_points + point_add					print "you now have %s points" % y					print "=" * 80					restart_program()				except ValueError:					print "That isn't a valid input!"					print "=" * 80					restart_program()		else:			print "that input is not valid!"			print "=" * 80			restart_program()
Link to comment
https://linustechtips.com/topic/100660-syntax-errors-in-python/
Share on other sites

Link to post
Share on other sites

ignore this, i fixed it myself

print """Welcome to the python, Linux friendly version of the book point tracker ver 1.0"""print "=" * 15#begin functionalitycurrent_points = raw_input("please enter current amount of points")print "You entered %s points, is this correct?" % current_pointsa = raw_input("0=NO, 1=YES")if a == 0:		print "please restart"	elif a == 1:		print "proceeding to next step"	else :		print "that is not a valid input"		print "=" * 15print "are you adding or subtracting points?"add_sub = raw_input("0=SUBTRACT 1=ADD")if add_sub == 0:		point_subtract = raw_input("how many points are you subtracting?")		print "you have taken %s points from %s points" % ( point_subtract, current_points)		x = (current_points - point_subtract)		print "you now have %s points" % x		print "if this number is negative, you don't have enough points! restart the program."	elif add_sub == 1:		point_add = raw_input("how many points are you adding?")		print "You are adding %s points to %s points." %( point_add, current_points)		y = (current_points + point_add)		print "you now have %s points" % y	else:		print "that input is not valid!"
Link to comment
https://linustechtips.com/topic/100660-syntax-errors-in-python/#findComment-1346942
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×