0

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
asked Sep 22, 2012 at 6:08
4
  • 3
    Please include the entire actual error message in your post. Also are you using Python 2 or 3? Commented Sep 22, 2012 at 6:10
  • Is this Python 2.7 or 3? Commented Sep 22, 2012 at 6:11
  • 2
    "print" is a function in python3 Commented Sep 22, 2012 at 6:25
  • print "The assessed value is $", assessed_value - the quotations on the right has the syntax... $" Commented Sep 22, 2012 at 6:27

3 Answers 3

5

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
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

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

1 Comment

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.