Discuss / Python / ”函数的参数“求助,def错误

”函数的参数“求助,def错误

再回首-知

#1 Created at ... [Delete] [Delete and Lock User]

求x的平方,输入代码 def power(x): return x * x

运算正常
但是求x的三次方,输入代码

def power(x, n): s = 1 while n > 0: n = n - 1 s = s * x return s 回车后就显示Syntax Error:invalid Syntax 为什么会出现这样的错误?应该怎么修改? Python是 3.6.0 电脑是Windows 7


  • 1

Reply