> Unfortunately, I don't understand how list comprehensions work and how to > implement them. Can someone point me in the right direction, please.
Compare these two pieces of code
x=[1,2,3,4]
y=[]
for eachnum in x:
y.append(eachnum * 2)
versus
x=[1,2,3,4]
y = [each * 2 for each in x]
Try them both on your box :^)
Alan
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor
