One-liner to print two statements in a for-loop in one line
List comprehension (I did not check your code, only rewrite it):
h = []
for i in input() : h.append(i.lower() if (ord(i) - 97) % 2 == 0 else i.upper())
print(*sorted(h, reverse=True))
print(*sorted([i.lower() if (ord(i)-97)%2 == 0 else i.upper() for i in input() ], reverse=True))
To quote your question:
you should print the original form of the character
That is not what the code does at the moment, just saying so you are aware.
after reading your deleted comment:
And if you are wondering about the if
and else
in list comprehension:
You can put it in your list, but if that was your problem (the actual question apparently) then I would suggest to use google, there are plenty of examples where this is used.: if/else in a list comprehension, https://towardsdatascience.com/a-gentle-introduction-to-flow-control-loops-and-list-comprehensions-for-beginners-3dbaabd7cd8a, https://pythonguides.com/python-list-comprehension-using-if-else/