Python Forum

Full Version: Mysterious syntax errors... help?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Trying to code, but keep on getting syntax errors. It says 'answer =' and 'return output
are improper. I am using python 3

def exponential():	base = int(input('Your base number:'))	exponent = int(input('Your exponential'))	answerexp = base ** exponent	output = '%s to the power of %s equals %s'%(str(base),str(exponent),str(answer))	return output def minus():	num1 = int(input('Your 1st number: '))	num2 = int(input('Your 2nd number: '))	answer = num1 - num2	output = "%s minus %s is equal to %s"%(str(num1),str(num2),str(ans))	return output def add():	num1 = int(input('Your 1st number: '))	num2 = int(input('Your 2nd number: '))	answer = num1 + num2	output = "%s plus %s is equal to %s" %(str(n1),str(n2),str(ans))	return output def sqroot():	number = int(input('Your number: '))	output = number ** (1. / 2)	return output def root():	exponent = int(input('Your number to root: '))	root = int(input('Your root to be used: '))	answer = exponent ** (1. / root)	output = '%s with the root of %s is %s'%(str(exponent),str(root),str(answer)	return output def func():	func = input("What do you want to do? ").lower()	if func == 'divide':	answer = divide()	print(answer)	func()	elif func == 'multiply' or 'times':	answer = multiply()	print(answer)	func()	elif func == ('power' or 'exponent') or ('exponential' or 'exponents'):	answer = exponential()	print(answer)	func()	elif func == 'minus' or 'subtract':	answer = minus()	print(answer)	func()	elif func == 'root':	answer = root()	print(answer)	func
On line 27 you're missing a close-parenthesis.
(Apr-26-2018, 08:50 PM)micseydel Wrote: [ -> ]On line 27 you're missing a close-parenthesis.

I have fixed that, but the errors persist.
When I take your code and make that one change, I don't get a syntax error. What's the exact, latest code you're using, along with its full error message? If you're using an IDE, it'd probably be worth getting the error message by using a terminal / console.