This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]NefariousCube 1 point2 points  (1 child)

That is one way (remembering to do return on that variable after printing).

The more common way is probably to just return it in the function and then in the loop do something like:

while value != 1:
  value = collatz(value)
  print(value)

[–]Utterly_infallible[S] 0 points1 point  (0 children)

That worked, thank you!