n = int(input())
while n > 0 :
k = raw_input()
if k.find(" ") != -1:
final = str(k[0].upper() + '.')
for i in range(len(k)) :
if (k[i] == ' ') & (k[i:].find(" ")):
final += k[i+1].upper() + ". "
else:
if(k[i] == ' '):
final += k[i+1].upper() + k[i+2:].lower()
n -= 1
print final[0:len(final)]
else :
print k[0].upper() + k[1:].lower()
I’ve tested this out personally, I don’t get why on submission i get a run time error.
Can anyone please clarify? Thanks.