Created
March 21, 2021 18:14
-
-
Save dhananjay1438/8ee02d156bf205ffa45c8975d092c1d5 to your computer and use it in GitHub Desktop.
Hackerrank problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = input() | |
string = sorted(string) | |
upper_case = [x for x in string if x.isupper()] | |
upper_case = sorted(upper_case) | |
lower_case = [x for x in string if x.islower()] | |
lower_case = sorted(lower_case) | |
numbers = [int(x) for x in string if x.isdigit()] | |
even_numbers = list() | |
odd_numbers = list() | |
for num in numbers: | |
if num % 2 == 0: | |
even_numbers.append(num) | |
else: | |
odd_numbers.append(num) | |
even_numbers = [str(x) for x in even_numbers] | |
odd_numbers = [str(x) for x in odd_numbers] | |
new_string = "".join(lower_case) + "".join(upper_case) + "".join(odd_numbers) + "".join(even_numbers) | |
print(new_string) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment