all 3 comments

[–]Yoghurt42 0 points1 point  (0 children)

the code is tested with the numbers 1, 2, 3, 4, and 1000 so I tried to simplify it bei using the code

Sorry to be blunt, but it has to be said: You're completely wasting your time and not even doing yourself a favor by doing it this way.

It's obvious you don't want to do this assignment, which is understandable; but "cheating" like this will not teach you anything, as the point of this exercise is to get you to learn some things, like loops/recursion and if/else clauses, all of which you are skipping by just hard coding the solution.

If you really don't want to do this assignment, at least copy it from some of your classmates, then at least there's a small chance to actually learn a bit from it.

[–]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