如何阻止在最后打印无。或者这是不可避免的?如何停止Python 3打印无
x = int(input("Please enter a number to print up to."))
def print_upto(x):
for y in range(1,x+1):
print(y)
print(print_upto(x))
非常感谢。
如何阻止在最后打印无。或者这是不可避免的?如何停止Python 3打印无
x = int(input("Please enter a number to print up to."))
def print_upto(x):
for y in range(1,x+1):
print(y)
print(print_upto(x))
非常感谢。
你的函数不返回任何值,它只是print
而已。所以返回值是None
。当你print(print_upto(x))
它等于print(None)
如果你想看到打印的值,你只需要调用print_upto(x)
没有任何print()
是你的缩进?如果你的函数正在打印,你不需要调用'print(print_upto(x))''print_upto(x)' – depperm