How to get a slice of a string with offset and length in Python

1 Answer

0 votes
s = "python java c++"

offset = 2
length = 4
slice_of_s = s[offset:offset+length]

print(slice_of_s)


'''
run:

thon

'''

 



answered Sep 17, 2018 by avibootz

Related questions

1 answer 185 views
185 views asked Nov 4, 2020 by avibootz
1 answer 230 views
1 answer 122 views
2 answers 161 views
1 answer 180 views
...