None
в конце - это None
, возвращаемое range_test
. Измените его на:
def range_test(start, end):
while start <= end:
print(start)
start+=1
range_test(1,5) # this function already prints, no need to print its return
или, если вы предпочитаете, чтобы range_test
возвращал что-то, что вы можете распечатать (вместо того, чтобы выполнять саму печать и ничего не возвращать), выполните:
def range_test(start, end):
to_print = ""
while start <= end:
to_print += f"{start}\n"
start+=1
return to_print
print(range_test(1,5))