Tom Tom - 2 months ago 16
Python Question

How to stop Python 3 printing none

how do I stop this from printing none at the end. Or is it inevitable?

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))


Many thanks.

Answer

instead of

print(print_upto(x))

on the last line, just do,

print_upto(x)`

thats it, and it will work fine.

Comments