r/pythonhelp • • Mar 07 '21

Capitalization Python: noob question

Hi, thanks for ur help in advance.

I have a string "I like cats and dogs and monkeys".

And I have a function that changes it to this:

"i like cats

and dogs and

monkeys."

How do I get it so the first letter of each line is capitalized? thanks

3 Upvotes

6 comments sorted by

View all comments

1

u/socal_nerdtastic Mar 07 '21

That depends on your function.

For a single string you would use the capitalize method:

>>> "i like cats".capitalize()
'I like cats'

1

u/LurkerFinallyJoins Mar 07 '21

Please let me post my function..one moment.

0

u/[deleted] Mar 07 '21

[deleted]

1

u/LurkerFinallyJoins Mar 07 '21

now I just want to add in the bit..where the first letter of each of the lines is capitalized. Any advice is appreciated