Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get a slice of string in python

string = "something"

slice = string[0:3] # will be "som"
slice = string[0:-3] # will be "someth"
slice = string[3:] # will be "thing"
slice = string[:3] # same as first slice
slice = string[::2] # will be "smtig" -- it goes 2 step each time
 
PREVIOUS NEXT
Tagged: #slice #string #python
ADD COMMENT
Topic
Name
7+4 =