【发布时间】:2022-11-20 12:46:45
【问题描述】:
I'm creating a recursive function that creates n lines of asterisk. I do not have problems on writing code, but just am wondering why None appears in my output.
Here is my code:
def recursive_lines(n):
for n in range(0,n):
print ('*' + ('*'*n)) # Print asterisk
print(recursive_lines(5)) # Enter an integer here
And this is the result:
*
**
***
****
*****
None
I don't think I used any int(print()) kind of statement here.. Then why does this error keep appearing?
【问题讨论】:
-
Does this answer your question? What is the purpose of the return statement? How is it different from printing?
标签: python python-3.x