Skip to content

Instantly share code, notes, and snippets.

@gideondsouza
Last active December 22, 2015 10:39
Show Gist options
  • Save gideondsouza/6460345 to your computer and use it in GitHub Desktop.
Save gideondsouza/6460345 to your computer and use it in GitHub Desktop.
Python Comprehensions 1
C:\Gideon\Coding>python
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> L1 = [1,2,3] #this is how you define a plain list
>>> L1 #type the variable and...
[1, 2, 3] #....this is what it's content looks like
>>> L2 = [x for x in range(20)] #now shove a for into a list and you have a dynamic list
>>> L2
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment