Unit 2 Task 44 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 44: Reverse digits of a sale code

← Back to task


One possible program:

original_code = int(input("Positive code: "))
reversed_code = 0
remaining = original_code

while remaining > 0:
    reversed_code = reversed_code * 10 + (remaining % 10)
    remaining //= 10

print("Reversed:", reversed_code)