感谢各位点进来,非常感谢! 问题如下:
def Ackermann(m, n):
if m == 0:
return n + 1
elif m > 0 and n == 0:
return Ackermann(m-1, 1)
elif m > 0 and n > 0:
return Ackermann(Ackermann(m-1, Ackermann(m, n-1))
else:
return('not definition')
Ackermann(int(input('enter your m:')), int(input('enter your n:')))
D:\--->python HelloWorld.py
File "HelloWorld.py", line 9
else:
^
SyntaxError: invalid syntax
这里面还有一个错误,我把 else 这行注释以后,还是提示我语法错误:
D:\--->python HelloWorld.py
File "HelloWorld.py", line 12
Ackermann(int(input('enter your m:')), int(input('enter your n:')))
^
SyntaxError: invalid syntax
1
imlonghao 2016-07-19 06:23:48 +08:00 via Android
Ackermann(Ackermann(m-1, Ackermann(m, n-1)))
|
2
msg7086 2016-07-19 06:24:06 +08:00
return Ackermann(
Ackermann( m-1, Ackermann( m, n-1 ) ) |
3
imlonghao 2016-07-19 06:25:26 +08:00 via Android
return 'not definition'
|
4
Pzdmultiverse OP |
5
imlonghao 2016-07-19 06:26:36 +08:00 via Android
忽略 3 楼
|
6
Pzdmultiverse OP @imlonghao python3 不是要打括号的么
|
7
mimzy 2016-07-19 06:45:46 +08:00 via Android
@Pzdmultiverse print 打括号 return 不用
|
8
Pzdmultiverse OP @mimzy soga
|