Digits the other way round
- O(1) · Trivial
- Free
- Python
- JavaScript
- digits
- operations
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):
passJavaScript
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
- Do the two times overlap?conditionals · booleans · comparisons
- Does it fall in range?conditionals · booleans · comparisons
- Does the photo fit the envelope?lists · conditionals · booleans
- How far apartoperations · comparisons
- How far from free shippingoperations · conditionals
- How far off is it?conditionals · comparisons · operations