You are on page 1of 1

#Write a program that accepts a string as an argument

#and returns a copy of the string with the 1st character of each sentence
capitalized

#define main
def main():
#declare variables
userSent = ''
finalStr = ''

userSent = input('Please enter your sentences: ')

print(f'"{userSent}" is the original string.')

#call function
#test - print(capitalSent(userSent))

finalStr = capitalSent(userSent)
print(f'"{finalStr}" is the edited string.')

#define sentence capitalizer function


def capitalSent(userStr):
capitalList = []

#split sentences by '. '


splitSent = userStr.split('. ')

for index in splitSent:


#take the first character of each split and capitalize it
capitalList.append(index[0].upper()+index[1:])
print(capitalList)

#test - print(capitalList)
finalStr = ". ".join(capitalList)

#test - print(finalStr)
return finalStr

#call main
if __name__ == '__main__':
main()

You might also like