I have a string that can either be written with caps lock or not. "With caps lock" means that it is either is like tHIS or like THIS. It is easy enough to detect the second case with "isupper()" function, but I wasn't able to find a way to find the first case reliably. For strings of length 1 I used "islower()" to detect if they should be capitalized, so it shouldn't be a problem
Code I used
import re
inp = input()
trutable = ""
for i in inp:
if i.isupper():
trutable += "1"
if i.islower():
trutable += "0"
pattern = re.compile(r'^01')
answ = re.match(pattern, trutable)
if inp.isupper() or answ != None or (len(inp) == 1 and inp.islower()):
inp = inp.capitalize()
print(inp)