Here is all my coding that I did but I keep getting this syntax error. It will be explained more at the bottom.
def main():
ActualValue()
AssessedValue()
printResult()
def ActualValue()
global actual_value
actual_value = float(input("Enter actual value:\t"))
def AssessedValue()
global assessed_value
global property_tax
assessed_value = 0.6 * actual_value
property_tax = assessed_value / 100 * 0.64
def printResult():
print "n\For a property valued at $", actual_value
print "The assessed value is $", assessed_value
print "The property tax is $", property_tax
actual_value = None
assessed_value = None
property_tax = None
main()
That is my code:
It keeps saying that I have a syntax error:
def printResult():
print "n\For a property valued at $", actual_value
print "The assessed value is $", assessed_value
print "The property tax is $", property_tax
Colin Dunklau
3,1111 gold badge24 silver badges20 bronze badges
-
3Please include the entire actual error message in your post. Also are you using Python 2 or 3?BrenBarn– BrenBarn2012年09月22日 06:10:30 +00:00Commented Sep 22, 2012 at 6:10
-
Is this Python 2.7 or 3?Rapptz– Rapptz2012年09月22日 06:11:38 +00:00Commented Sep 22, 2012 at 6:11
-
2"print" is a function in python3georg– georg2012年09月22日 06:25:13 +00:00Commented Sep 22, 2012 at 6:25
-
print "The assessed value is $", assessed_value - the quotations on the right has the syntax... $"Issa Sahawneh– Issa Sahawneh2012年09月22日 06:27:28 +00:00Commented Sep 22, 2012 at 6:27
3 Answers 3
You have the \n escape sequence backwards.
Also, you need to make sure all your function definitions have a colon on the end of the line.
Also, print is a function in Python 3.
answered Sep 22, 2012 at 6:12
Platinum Azure
46.4k13 gold badges112 silver badges137 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
print is a function in Python 3:
def printResult():
print("\nFor a property valued at $", actual_value)
print("The assessed value is $", assessed_value)
print("The property tax is $", property_tax)
I fixed your \n newline escape code for you as well.
You probably want to use the .format() method to format your output:
def printResult():
print("\nFor a property valued at ${0}".format(actual_value))
print("The assessed value is ${0}".format(assessed_value))
print("The property tax is ${0}".format(property_tax))
answered Sep 22, 2012 at 6:54
Martijn Pieters
1.1m326 gold badges4.2k silver badges3.5k bronze badges
Comments
Just to clarify what Platinum Azure said.
def main():
actualValue()
assessedValue()
printResult()
def actualValue():
global actual_value
actual_value = float(input("Enter actual value:\t"))
def assessedValue():
global assessed_value
global property_tax
assessed_value = 0.6 * actual_value
property_tax = assessed_value / 100 * 0.64
def printResult():
print "\nFor a property valued at $", actual_value
print "The assessed value is $", assessed_value
print "The property tax is $", property_tax
actual_value = None
assessed_value = None
property_tax = None
main()
This should work
answered Sep 22, 2012 at 7:25
Pablo Jomer
10.5k11 gold badges60 silver badges106 bronze badges
1 Comment
Pablo Jomer
Its also good to use the standard language variable name case. In python ActualValue is a class name a method should be actualValue or better actual_value
lang-py