On 6/24/05, dimitri pater <[EMAIL PROTECTED]> wrote:
>  a = 'harry is a strange guy. so is his sister, but at least she is not a
> guy. i am.'
>  b = a.replace('. ', '.')
>  splitlist = b.split('.')
>  newlist = []
>  for i in range(len(splitlist)):
>       i = ''.join(splitlist[i].capitalize() + '.'
>       newlist.append(i)
>  cap = ' '.join(newlist).replace(' .', '')
>  print cap

A simpler version would be:

>>> s = 'harry is a strange guy. so is his sister, but at least she is not a guy
. i am.'
>>> a = s.split('. ') # you can split at multicharacter strings
>>> b = (x.capitalize() for x in a) # you can use generator
expressions to generate lists
>>> '. '.join(b)
'Harry is a strange guy. So is his sister, but at least she is not a guy. I am.'

>  it doesn't work with:
>  is harry a strange guy? so is his sister, but at least she is not a guy. i
> am.

I believe you'll need re.split to accomplish that.

Regards,
- kv
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to