I have the following piece of code in Python which tries to put a function that prints something in a print statement.
def my_print(num: int) -> None:
for i in range(num):
print(i, end=' ')
if __name__ == '__main__':
print('When num is 5 :', my_print(5))
I expect to get something like
When num is 5 : 0 1 2 3 4
But I actually get
0 1 2 3 4 When num is 5 : None
Could someone please explain the logic behind the print function in this case and where that None comes from at the end? Thanks.