Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

How to Slice list

# 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)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #How #Slice #list
ADD COMMENT
Topic
Name
6+7 =