I want to make number sorter that can sort number: Input: 90213 Output: 93210 Here is my code:
broj = int(input())
b = [broj]
print(b.sort(reverse=True))
When it runs it outputs None.
I want to make number sorter that can sort number: Input: 90213 Output: 93210 Here is my code:
broj = int(input())
b = [broj]
print(b.sort(reverse=True))
When it runs it outputs None.
This will do the trick:
broj = input()
print(''.join(sorted(broj, reverse=True)))
You don't have to convert it to a int:
value = input() # value is a string
sorted_value = sorted(value, reverse=True) # sorted_value is a list like ['9', '3', '2', '1', '0']
print("".join(sorted_value)) # "".join() joins all the elements from the list to one string