Chinaunix
标题:
新手请帮忙,谢谢
[打印本页]
作者:
masaic117
时间:
2011-03-04 19:20
标题:
新手请帮忙,谢谢
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
还有这么一段
def sayHello():
print 'Hello World!' # block belonging to the function
sayHello()
运行时提示:SyntaxError: invalid syntax
是为什么?
作者:
eookoo
时间:
2011-03-06 04:43
把完整的 error message 貼上來吧....
就這樣看沒什麼問題, 除非你用的是 3.0 以上, 你的 print 就有問題
作者:
werm520
时间:
2011-03-06 10:14
我也是刚学
我是 3.1版本的,刚刚编译了下,这样就有输出了
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print (factorial(6))
第二个,也应该是print格式的问题
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2