For the given string str = "Hello PYTHON" write the positive & negative index and also write the OP for the following statement
str 71 =
str [1] str [- 3]
Answers
Answered by
5
str = 'Hello PYTHON'
Positive indexing:
Negative indexing:
Output for str[1]:
- 'e'
Output for str[-3]:
- 'H'
String slicing refers to the act of retrieving a substring from a given string. It is done using index values. Positive indexing indicates that the string is being traversed from left to right, while negative indexing traverses from right to left.
Similar questions
Social Sciences,
1 month ago
India Languages,
1 month ago
Political Science,
1 month ago
History,
3 months ago
Hindi,
3 months ago
English,
9 months ago
Math,
9 months ago