String Slicing in Python
Learn Negative Index and String Slicing, I tried my best to make this comfortable for everyone but there might be mistakes so let me know that i'll prolly correct that in a month:(
Negative Index
As you know String's First Character's Index is 0, Sec...
dev2-python.hashnode.dev4 min read
Thank you for sharing this Dev2, nicely written article.
you can add this: Slicing with positive and negative index
Code:
s = "Welcome to scaler" s1 = s[3 : -7] print("positive start index, negative end index:", s1) # above slice operation can also be written as s2 = s[-14 : 10] print("negative start index, positive end index:", s2)Output:
positive start index, negative end index: come to negative start index, positive end index: come toCheck this String Slicing in Python article on Scaler Topics.