0
def triangle_area(base, height):    
    area = (1.0 / 2) * base * height
    return area

a1 = triangle_area(3, 8)
print (a1)

SyntaxError: invalid syntax (in a1) why?

another example

def x(a,b):
    q=a+b
    return q
y=x(3,9)
SyntaxError: invalid syntax (in line y=x(3,9))
user3481415
  • 13
  • 1
  • 4

1 Answers1

1

If you're using Python 3, print is a function, not a statement like it was in Python 2. You need to put parentheses around a1 in your last line to make it a function call:

print(a1)
Blckknght
  • 100,903
  • 11
  • 120
  • 169
  • The code you've shown works for me, once the `print` issue is taken care of. If you're having an issue still, you'll need to provide more information about it. Can you edit to include the full traceback? – Blckknght Mar 31 '14 at 15:12