[Tutor] lists
Pijus Virketis
virketis@fas.harvard.edu
Tue, 26 Mar 2002 07:24:41 -0500
Ian,
> How can I make the for loop work with whole strings at a time, instead of
> characters?
Try the following small adjustment:
>>> somewords = ['goo', 'foo', 'loo', 'moo', 'too']
>>> fillme = []
>>> for word in somewords:
... fillme.append(word) #using the append() method rather than
the increment operator
>>> fillme
['goo', 'foo', 'loo', 'moo', 'too']
This is a very typical task, and append() seems to me to be the best way of
doing it.
Cheers,
Pijus