Explanation:
String Indexing
- The string "Python" consists of characters indexed as follows:
- Each character has a corresponding index, starting from 0.
- The string "Python" consists of characters indexed as follows:
String Slicing (x[2:5])
- The slice notation [start:stop] extracts characters from index start up to (but not including) stop.
- Here, x[2:5] means:
- Start from index 2 ('t')
- Go up to index 5 (which is 'n' but not included)
- The extracted portion is 'tho'.
0 Comments:
Post a Comment