Skip to content

Latest commit

 

History

History
42 lines (22 loc) · 680 Bytes

Descending_Order.md

File metadata and controls

42 lines (22 loc) · 680 Bytes

CodeWars Python Solutions


Descending Order

Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number.

Examples

Input: 21445 Output: 54421

Input: 145263 Output: 654321

Input: 123456789 Output: 987654321


Given Code

def descending_order(num):
    pass

Solution

def descending_order(num):
    return int("".join(sorted([num for num in str(num)], reverse=True)))

See on CodeWars.com