Skip to content

Instantly share code, notes, and snippets.

@jamesrajendran
Created June 24, 2017 06:38
Show Gist options
  • Save jamesrajendran/c1689f5021451b64907ac9740a55593c to your computer and use it in GitHub Desktop.
Save jamesrajendran/c1689f5021451b64907ac9740a55593c to your computer and use it in GitHub Desktop.
// List Comprehension
Example 1
x = [1,2,3,4]
y = sum(1 for i in x)
y
Example 2
doubled = ( num * 2 for num in x )
for i in doubled: print(i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment