Skip to content

Instantly share code, notes, and snippets.

@Robofied
Created February 5, 2019 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robofied/d1e6674c44acc362047af9bf4827a732 to your computer and use it in GitHub Desktop.
Save Robofied/d1e6674c44acc362047af9bf4827a732 to your computer and use it in GitHub Desktop.
l1 = [1,2,3,4]
print(l1)
#[Output]:
[1, 2, 3, 4]
print(l1[0])
print(l1[1])
#[Output]:
#1
#2
## Slicing method to access the element
## It will not include the end index
print(l1[0:3])
## Accesssing full list
print(l1[:])
## With skip also ## here it will skip 1 value and then takes another.
## Same as for(i=0;i<n;i=1+2) if you have done c or c++, java programmin before. print(l1[0::2])
## Access from last
print(l1[:-2])
#[Output]:
#[1, 2, 3]
#[1, 2, 3, 4]
#[1, 3]
#[1, 2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment