list problem...

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Sep 29 14:17:13 CEST 2010


On Tue, 28 Sep 2010 20:11:51 +0100, Rog wrote:

> On Tue, 28 Sep 2010 11:59:08 -0700, geremy condra wrote:
> 
>> On Tue, Sep 28, 2010 at 11:44 AM, Rog <rog at pynguins.com> wrote:
>>> Hi all,
>>> Have been grappling with a list problem for hours... a = [2, 3, 4,
>>> 5,.....]
>>> b = [4, 8, 2, 6,.....]
>>> Basicly I am trying to place a[0], b[0] in a seperate list IF a[2] and
>>> b[2] is present.
>>> I have tried sets, zip etc with no success. I am tackling Euler
>>> projects with Python 3.1, with minimal knowledge, and having to tackle
>>> the language as I progress. Enjoyable frustration  :)
>> 
>> I'm not clear on what your actual problem is, could you restate it?
>> 
>> It sounds like you want to copy the ith element out of a and b into
>> some other list- call it c- when the (i+2)th element meets some
>> condition. What's the condition?
>> 
>> Geremy Condra
> 
> The condition is that the i-th element is inverted, but not equal. eg
> 4,2 - 2,4 , 34,5 - 5,34 etc.
> Hope that is clearer.

Clear as mud.

Perhaps you should given an example. Given input 

a = [2, 3, 4, 5, 6, 7]
b = [4, 8, 2, 6, 10, 42]

what output are you expecting, and how would you work it out by hand?





-- 
Steven



More information about the Python-list mailing list