Invert Case - EDITORIAL:
Given a string, check if it has alphanumeric characters. If yes, invert the cases of the alphabets in it and print it, else print -1.
The question is straight-forward. The main aim was to reduce the source code size. In python, there are in-built functions for strings like .isalnum() for checking if there are alphanumeric characters, and .swapcase() for inverting cases of the alphabets.
Check out the setter’s solution which uses 82 characters. This solution can be improved more. Feel free to share your approach, if it differs. Suggestions are always welcomed.
for i in range(int(input())): s=input() print(s.swapcase()if s.isalnum()else -1)