String Slicing Concepts
s = "You are learning Python"
print(s[:]) # outputs "You are learning Python" print(s[1:6]) # outputs "ou ar", because s[1] is "o", s[5] is "r" print(s[10:]) # outputs "arning Python" because it's the slice from index 10 to the end of the string print(s[:10]) # outputs "You are le" because it's the slice from the start to index 9
Comments
Post a Comment