We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
word = input()
lower_letters = sorted([char for char in word if char.islower()])
upper_letters = sorted([char for char in word if char.isupper()])
odd_digits = sorted([num for num in word if not num.isalpha() and int(num)%2 != 0])
even_digits = sorted([num for num in word if not num.isalpha() and int(num)%2 == 0])
ginortS
You are viewing a single comment's thread. Return to all comments →
Easy and simplet to understand code.
word = input() lower_letters = sorted([char for char in word if char.islower()]) upper_letters = sorted([char for char in word if char.isupper()]) odd_digits = sorted([num for num in word if not num.isalpha() and int(num)%2 != 0]) even_digits = sorted([num for num in word if not num.isalpha() and int(num)%2 == 0])
sorted_word = ''.join(lower_letters + upper_letters + odd_digits + even_digits)
print(sorted_word)