I was trying to write a range function below however it printed out "None" after every line. Please help fix them.
def odd_number(n):
num = []:
for x in range(1, n+1):
if x % 2 != 0:
num.append(x)
print(num)
print(odd_numbers(5))
print(odd_numbers(10))
When I hit print the results came out as
[1, 3, 5]
None
[1, 3, 5, 7, 9]
None
instead of
[1, 3, 5]
[1, 3, 5, 7, 9]
Please help explain what I was doing wrong and help with fixing it.
Thank you