[Tutor] (no subject)

Joel Goldstick joel.goldstick at gmail.com
Wed Jun 10 12:55:56 CEST 2015


On Wed, Jun 10, 2015 at 6:36 AM, rakesh sharma
<rakeshsharma14 at hotmail.com> wrote:
>
> I have come across this syntax in python. Embedding for loop in []. How far can things be stretched using this [].
> l = [1, 2, 3, 4, 5]
> q = [i*2 for i in l]
> print qthanksrakesh

This is called a list comprehension.  They are a more concise way of
writing various for loops.  You can google to learn much more
-- 
Joel Goldstick
http://joelgoldstick.com


More information about the Tutor mailing list