Skip to content

Instantly share code, notes, and snippets.

@xiangzhuyuan
Created February 25, 2012 15:34
Show Gist options
  • Save xiangzhuyuan/1909106 to your computer and use it in GitHub Desktop.
Save xiangzhuyuan/1909106 to your computer and use it in GitHub Desktop.
list comperhension
for i in range(4):
for j in range(5):
a=i*j
print a
print [i*j for i in range(4) for j in range(5)]
@xiangzhuyuan
Copy link
Author

the output:
[0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 2, 4, 6, 8, 0, 3, 6, 9, 12]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment