String Slicing
Accessing substrings with slicing
Interview Relevant: Common interview topic
Slicing
Extracting parts of a string.
Code Examples
String slicing syntax.
python
1s = "Python"
2s[0] # 'P'
3s[-1] # 'n' (last char)
4s[0:2] # "Py"
5s[2:] # "thon"
6s[::-1] # "nohtyP" (Reverse)