Skip to content

Instantly share code, notes, and snippets.

@pgainda
Created October 23, 2013 18:04
Show Gist options
  • Save pgainda/7123566 to your computer and use it in GitHub Desktop.
Save pgainda/7123566 to your computer and use it in GitHub Desktop.
If you don't pass a particular index to the list slice, Python will pick a default. The default for the starting index is the first element of the list; the default for the ending index is the final element of the list; and the default for the stride index is 1.
my_list = range(1, 11) # List of numbers 1 - 10
#Every odd number
print my_list[::2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment