Answers for "slice operator in python list"

0

python slice operator

string = 'string_text'

beginning = 0 # at what index the slice should start.
end = len(string) # at what index the slice should end.
step = 1 # how many characters the slice should go forward after each letter

new_string = string[beginning:end:step]

# some examples
a = 0
b = 3
c = 1

new_string = string[a:b:c] # will give you: str
# ____________________________________________
a = 2
b = len(string) - 2
c = 1

new_string = string[a:b:c] # will give you: ring_te
Posted by: Guest on February-24-2021

Python Answers by Framework

Browse Popular Code Answers by Language