Cool! Thank you very much. You mean this instead right?
print [x*x for x in xrange(1,11,2)]
Kit
On 1月19日, 上午8時36分, Gary Herron wrote:
> Kit wrote:
> > Thank you so much guys.
>
> > Just out of curiosity: can I do something like this to "square all
> > e
Oops...
> print [x^2 for x in range (1,11) if x % 2 == 0]
print [x^2 for x in range (1,10) if x % 2 == 0]
On 1月19日, 上午8時24分, Kit wrote:
> Thank you so much guys.
>
> Just out of curiosity: can I do something like this to "square all
> even numbers in the range 1-10&quo
Thank you so much guys.
Just out of curiosity: can I do something like this to "square all
even numbers in the range 1-10"?
print [x^2 for x in range (1,11) if x % 2 == 0]
Or is there a better way of doing it? Thanks for the help, and I am
really appreciate your help.
Kit.
On 1月19日
Hello Everyone, I am not sure if I have posted this question in a
correct board. Can anyone please teach me:
What is a list compression in Python?
Would you mind give me some list compression examples?
Thanks & really appreciate that.
Kit
--
http://mail.python.org/mailman/listinfo/python-list