LAZR.PW
Stuff I'm working on.

Thursday, 19 June 2014

Python Witchcraft

How did I live without this?

nums = [1, 2, 3, 4, 5]
squares = [x*x for x in nums]
print (squares)

[1, 4, 9, 16, 25]

In case you missed it, that was a for each loop inside an array declaration.

No comments:

Post a Comment