You are asked to ensure that the first and last names of people begin with a capital letter in their passports. For example, alison heck should be capitalised correctly as Alison Heck.
the code I've tried:
def solve(s):
words = s.split()
flag = False
for word in words:
if isinstance(word[0], str):
flag = True
else:
flag = False
if flag:
return s.title()
else:
# don't know what to do
s = input()
print(solve(s))
this code works fine for most cases except for one,
frustrating testcase: '1 w 2 r 3g', and the output should be '1 W 2 R 3g', but since we are using the .title() method last 'g' will also be capitalized.