def capitalize_first_last(s):
return " ".join(word[:-1].capitalize() + word[-1].capitalize() for word in s.split())
s = "python isan interpreted general purpose programming language"
print(capitalize_first_last(s))
'''
run:
PythoN IsaN InterpreteD GeneraL PurposE ProgramminG LanguagE
'''