Skip to the content

Digits the other way round

Problem

Write a function that takes a two-digit number (from 10 to 99) and returns the number you get by swapping its digits: 47 becomes 74. What you return is a number, not a text.

If the number ends in 0, the one that comes back has a single digit: 50 becomes 5.

Examples

  • 47 → 74

  • 12 → 21

  • 99 → 99

Besides these, the challenge has hidden tests that are revealed when you submit your solution.

You start with this

Python

def flip_digits(n):
    pass

JavaScript

function flipDigits(n) {
}
Solve this challenge

It opens in your browser, with the editor and the tests. It is free and you do not need an account to start.

More O(1) challenges

See all challenges →