--- Matthew White <[EMAIL PROTECTED]> wrote:
> Hi Hoffman,
>
> It is often useful to use the "for" construct to
> process items in a list.
> e.g.:
>
> >>> list1 = [ 'spam!', 2, ['Ted', 'Rock']]
> >>> for item in list:
> ...print item
> spam!
> 2
> ['Ted', 'Rock']
>
> If you pass a list to
--- Terry Carroll <[EMAIL PROTECTED]> wrote:
> On Mon, 10 Apr 2006, Hoffmann wrote:
>
> > Hello,
> >
> > I have a list: list1 = [ 'spam!', 2, ['Ted',
> 'Rock']
> > ]
> > and I wrote the script below:
> >
> > i = 0
> > while i < len(list1):
> > print list1[i]
> > i += 1
> >
> > Ok. Thi
On Mon, 10 Apr 2006, Hoffmann wrote:
> I also would like to print the length of each element
> of that list:
>
> spam! = 1 element
> 2 = 1 element
> ['Ted', 'Rock'] = 2 elements
>
> Could anyone, please, give me some hints?
The problem is slightly weird, just because you need to clarify what i
On Mon, 10 Apr 2006, Hoffmann wrote:
> Hello,
>
> I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock']
> ]
> and I wrote the script below:
>
> i = 0
> while i < len(list1):
> print list1[i]
> i += 1
>
> Ok. This script will generate as the output each
> element of the original list, on
--- John Fouhy <[EMAIL PROTECTED]> wrote:
> Hi Hoffmann,
>
> On 11/04/06, Hoffmann <[EMAIL PROTECTED]> wrote:
> > I have a list: list1 = [ 'spam!', 2, ['Ted',
> 'Rock'] ]
> > and I wrote the script below:
> >
> > i = 0
> > while i < len(list1):
> > print list1[i]
> > i += 1
>
> Have you
Hi Hoffman,
It is often useful to use the "for" construct to process items in a list.
e.g.:
>>> list1 = [ 'spam!', 2, ['Ted', 'Rock']]
>>> for item in list:
...print item
spam!
2
['Ted', 'Rock']
If you pass a list to the len() function, it will return the number of
elenents in the list. e.g
--- Adam <[EMAIL PROTECTED]> wrote:
> On 10/04/06, Hoffmann <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > I have a list: list1 = [ 'spam!', 2, ['Ted',
> 'Rock']
> > ]
> > and I wrote the script below:
> >
> > i = 0
> > while i < len(list1):
> > print list1[i]
> > i += 1
> >
> > Ok. This s
On 10/04/06, Hoffmann <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock']
> ]
> and I wrote the script below:
>
> i = 0
> while i < len(list1):
> print list1[i]
> i += 1
>
> Ok. This script will generate as the output each
> element of the original
Hi Hoffmann,
On 11/04/06, Hoffmann <[EMAIL PROTECTED]> wrote:
> I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock'] ]
> and I wrote the script below:
>
> i = 0
> while i < len(list1):
> print list1[i]
> i += 1
Have you read about "for" loops? The pythonic way of looping through
a list
Hello,
I have a list: list1 = [ 'spam!', 2, ['Ted', 'Rock']
]
and I wrote the script below:
i = 0
while i < len(list1):
print list1[i]
i += 1
Ok. This script will generate as the output each
element of the original list, one per line:
spam!
2
['Ted', 'Rock']
I also would like to print
10 matches
Mail list logo