Re: iterating over list with one mising value



On Tue, Feb 7, 2012 at 5:27 AM, Sammy Danso <samdansobe@xxxxxxxxx> wrote:

Hello experts,
I am having trouble accessing the content of my list.
my list content has 2-pair value with the exception of one which has single value. here is an example  ['a', 1, 'b', 1, 'c', 3, 'd']

I am unable to iterate through list to access invidual value pairs

I get an error message saying ' the list should more than 1 value pairs'. I guess because 'd' has no value. How do I solve this problem?

What are you using to iterate through pairs instead of individual
elements? It sounds like it is not very flexible. I would recommend
instead using the "grouper" recipe from the itertools documentation:

http://docs.python.org/library/itertools.html#recipes

Cheers,
Ian
.



Relevant Pages

  • Re: iterating over list with one mising value
    ... On 02/07/2012 07:27 AM, Sammy Danso wrote: ... I am having trouble accessing the content of my list. ... I am unable to iterate through list to access invidual value pairs ... Of course if you actually posted the code, or even the real and complete error message, we might be able to make other suggestions. ...
    (comp.lang.python)
  • Re: Premature optimization (was Re: Structures
    ... tim wrote: ... going to get me in trouble later and what is not. ... iterate anywhere you can map. ... and profile it if it's too slow. ...
    (comp.lang.lisp)
  • Re: problem with string
    ... Care to tell us what the error message is, or is it a state secret that ...
    (comp.lang.python)
  • Attachment Collection Problem !!!
    ... I have a problem trying to iterate through the Attachment ... still get an error message as follows. ... Index (zero based) must be greater than or equal ... SqlParameter("@BlobField", att)); ...
    (microsoft.public.outlook.interop)