File "C:\Users\Administrator\Desktop\樱花树.py", line 5 def tree(n, 1); ^ SyntaxError: invalid syntax [Finished in 229ms]
时间: 2024-05-01 08:16:48 浏览: 65
invalid syntax 是一个 Python 的语法错误
There is a syntax error in the code. The semi-colon after "1" in the function declaration should be a colon. The corrected code should be:
```
def tree(n, i):
if n > 0:
tree(n-1, i+1)
print(" "*(i-1) + "*"*(n*2-1))
```
阅读全文