ToshiBoy,
You might want to take a look at the filter() function, it can also be used
for the kind of the thing you're doing.
http://docs.python.org/tut/node7.html#SECTION00713
>>> B = range(1,27)
>>> def test(b):
... if b*b in B:
... return True
... else:
...
On Jun 28, 2:48 pm, Mel <[EMAIL PROTECTED]> wrote:
> ToshiBoy wrote:
> > I have two lists A and B that are both defined as range(1,27) I want
> > to find the entries that are valid for A = BxB
> [ ... ]
> > I get, as expected 1,4,9,16,25 printed out being the only members of B
> > where the conditi
ToshiBoy wrote:
> I have two lists A and B that are both defined as range(1,27) I want
> to find the entries that are valid for A = BxB
[ ... ]
> I get, as expected 1,4,9,16,25 printed out being the only members of B
> where the condition is true, but when I print B I get:
>
> [1, 2, 3, 4, 5, 7, 9
Le Saturday 28 June 2008 06:30:25 ToshiBoy, vous avez écrit :
> I am a newbie... and the first to admit it... but this has me stuffed:
>
> I have two lists A and B that are both defined as range(1,27) I want
> to find the entries that are valid for A = BxB
>
> so here is my code:
>
> A = range(1,27
I am a newbie... and the first to admit it... but this has me stuffed:
I have two lists A and B that are both defined as range(1,27) I want
to find the entries that are valid for A = BxB
so here is my code:
A = range(1,27)
B = range(1,27)
for b in B:
if b*b in A:
print b