2013-01-19 72 views
6

Possible Duplicate:
Syntax error on print with Python 3無效的語法打印在Python 3.3.0

我嘗試做階乘在Python 3和任何我已經把它告訴我同樣的事情「無效語法:語法錯誤」 ......爲什麼給我一個錯誤 ?感謝

版本

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

這是我嘗試做

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

,當我嘗試打印

>>> print fact(23) 

它告訴我語法錯誤:無效的語法

回答

9

在pyt hon 3.x print是一個功能。改爲嘗試print(fact(23))