list_example = ["python","ruby","java","javascript","c#","css","html"]
print(list_example[3])#javascript
print(list_example[0])#python
print(list_example[6])#html
print(list_example[0:3]) #will print the programming language under python and javascript
print(list_example[:3]) all languages under python to javascript
# List slicing in Python
my_list = ['p','r','o','g','r','a','m','i','z']
# elements from index 2 to index 4
print(my_list[2:5])
# elements from index 5 to end
print(my_list[5:])
# elements beginning to end
print(my_list[:])
# List slicing in Python
my_list = ['p','r','o','g','r','a','m','i','z']
# elements from index 2 to index 4
print(my_list[2:5])
# elements from index 5 to end
print(my_list[5:])
# elements beginning to end
print(my_list[:])
#['o', 'g', 'r']
#['a', 'm', 'i', 'z']
#['p', 'r', 'o', 'g', 'r', 'a', 'm', 'i', 'z']
# Python program to demonstrate
# Removal of elements in a List
# Creating a List
List = ['S','O','F','T','H','U',
'N','T','.','N','E','T']
print("Initial List: ")
print(List)
# Print elements of a range
# using Slice operation
Sliced_List = List[3:8]
print("
Slicing elements in a range 3-8: ")
print(Sliced_List)
# Print elements from a
# pre-defined point to end
Sliced_List = List[5:]
print("
Elements sliced from 5th "
"element till the end: ")
print(Sliced_List)
# Printing elements from
# beginning till end
Sliced_List = List[:]
print("
Printing all elements using slice operation: ")
print(Sliced_List)
This slice object can take three arguments;
slice(start, end, step)
fruits = ["apple", "banana", "peach", "pear", "plum", "orange"]
x = slice(1, 4, 2)
fruits[x]