#224 · Math · Beginner · 30 XP · about 5 min
Write reverse_integer(n) that returns the integer you get by writing the digits of n in reverse order. A negative number stays negative, and zeros that end up at the front disappear, as they would in any number.
reverse_integer(1234) # returns 4321 reverse_integer(-56) # returns -65 reverse_integer(120) # returns 21 reverse_integer(0) # returns 0
Return an int, not a string. You can work with the text of the number or with % 10 and // 10: both are fine.
First solves only, ranked by stars and then time.