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 ass2 = s[-14 : 10]
print("negative start index, positive end index:", s2)
Output:
positive startindex, negative endindex: come to
negative startindex, positive endindex: come to
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.