I am new to programming, while studying, I came across this practice project which is to write a program to run the collatz sequence from any number until it reaches 1, the code works but it prints each output twice.
`def collatz():
if number % 2 == 0:
print(number // 2)
return number // 2
else:
print(number * 3 + 1)
return number * 3 + 1
number = 5
print("hi pick a number")
while number != 1:
try:
number = int(input())
while number != 1:
collatz()
number = collatz()
except ValueError:
print("you should pick a number!")`
hi pick a number
16
8
8
4
4
2
2
1
1
>Solution :
In your code you call twice collatz() so it print twice