[Tutor] Errr...Capitalizing Words

Sharriff Aina NHYTRO@compuserve.com
Fri, 16 Feb 2001 04:22:37 -0500

Hi Britt!

In this case I would store the text in a variable then loop a  function
that contains a "Regular expression" over it.. The exprssion sorts out th=
first words in a sentences and capitilizes it.

Hope that helps somehow


Message text written by INTERNET:tutor@python.org
>Message: 13
From: "Britt Green" <britt_green@hotmail.com>
To: tutor@python.org
Date: Thu, 15 Feb 2001 20:38:58 -0800
Subject: [Tutor] Errr...Capitalizing Words


I'm kind of stuck on something seemingly trivial, and I'm hoping someone
can =

help me out. Say I have a block of text, all in lower case:

this is some sample text. its all in lower case. there are no capitals in=

this block of text. you get the idea, and now i'm just typing to make a l=

of text.

What I want to do with Python is take the first letter of each sentance a=

capitalize it. By looking into the string library I've found the =

string.capitalize() function. This only seems to work if you know the wor=
d =

you're trying to use. Then string.capwords() will capitalize each word =

instead of just the first one.

Can anyone point me in the right direction for this?