0

How would you write this program in Python IDLE?

Write a program with a function that accepts a string as an argument and returns (some type of return value) a copy of the string with the first character of each sentence capitalized. For instance, if the argument is "hello. my name is Joe. what is your name?" the function should return a string "Hello. My name is Joe. What is your name?" The program should let the user enter a string and then pass it to the function. The modified string should be displayed.

I need help writing this program! I would greatly appreciate it. This all has to do with strings. Im learning the basics of Python, so just writing this program in basic concepts would be best.

Thank You

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by pyTony
0

We wait to see your efforts (inside CODE tags) and point you to right direction.

Edited by happygeek: fixed formatting

0

Python has a some string functions that will help, but you need to add your spaces and periods back in. Experiment a little and have fun ...

s = "hello. my name is Joe. what is your name?"

sentence_list = s.split('.')
print(sentence_list)

for sentence in sentence_list:
    sentence = sentence.strip()
    print(sentence.capitalize())

''' my result -->
['hello', ' my name is Joe', ' what is your name?']
Hello
My name is joe
What is your name?
'''
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.