Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

invalid syntax print in Python 3.3.0 [duplicate]

Possible Duplicate:
Syntax error on print with Python 3

im trying to do factorial in python 3 and whatever I have put it tells me the same thing "Invalid syntax: syntax error"...Why is it giving me an error ? thanks

version is

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64 bit (AMD64)] on win32

this is what im trying to do

>>> def fact(n):
... res = 1
... while n > 1: 
... res *= n
... n -= 1
... return res

and when i try to print

>>> print fact(23)

it tells me SyntaxError: invalid syntax

like image 237
Mirza Avatar asked Jan 19 '13 05:01

Mirza


1 Answers

In python 3.x print is a function. Try print(fact(23)) instead.

like image 120
GWW Avatar answered Sep 25 '22 20:09

GWW