newbie.string.listless

Ignacio Vazquez-Abrams ignacio at openservices.net
Fri Aug 31 23:06:08 EDT 2001


On Fri, 31 Aug 2001, FMH wrote:

> names = ["one,"who","two","three"]
>
> for i in names[:]:
>  if i in names[:]:
>   i = string.capitalize(i)
>   print i,
>
>
> One Who Two Three
> >>> i
> 'Three'

Use map() instead:

---
>>> import string
>>> names = ["one", "who", "two", "three"]
>>> newnames=map(string.capitalize, names)
>>> newnames
['One', 'Who', 'Two', 'Three']
>>>
---

-- 
Ignacio Vazquez-Abrams  <ignacio at openservices.net>





More information about the Python-list mailing list