Created
February 5, 2019 06:34
-
-
Save Robofied/d1e6674c44acc362047af9bf4827a732 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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