If you mean for j to be a list of foobar(item) then use
j=[foobar(item) for item in x]

The first part of the list comp can be any valid expression.

Kent

Liam Clarke wrote:
Hi,

Am I able to achieve something like this -

def foobar();
# stuff
return

x=[1,....1000]

for j=foobar(item) for item in x:

As a comprehension, if you get what I mean... Can I build a for loop
with a function in  for x in x part?

Ack. Having difficulty summing it up properly.



_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to