Correct option is B
Negative slicing is used to extract elements from the end of a string.
Important Key Points:
1. Negative slicing in Python allows accessing string elements starting from the end of the string using negative indices.
2. For example, "Python"[-1] returns 'n', the last character of the string.
3. Using [::-1] as a slicing pattern reverses the string completely.
Knowledge Booster:
· Reversing a string is achieved using [::-1], but negative slicing itself doesn’t reverse the string.
· Adding elements to a string is not possible, as strings in Python are immutable.
· Finding the length of a string is done using the len() function, not slicing.
· Replacing characters in a string is done using the replace() method.