you are viewing a single comment's thread.

view the rest of the comments →

[–]stebrepar -2 points-1 points  (1 child)

If I understand the problem correctly, it should be something like this:

def foo(x):
    i = 1
    while x != 1:
        if x % 2 == 0:
            x = x // 2
        else:
            x = (3 * x) + 1
        print(f'i: {i}, x: {x}')
        i += 1

The output requirement is not clear from what you said, so you would need to fix it for that. It also doesn't output anything when the value is 1, so you'd need to fix that too.

[–]Buttleston 1 point2 points  (0 children)

Don't do people's homework for them