Given a string, we have to access characters from the string in Python.
Example:
Input:
str: "Hello world"
Output:
First character: H
Second character: e
Last character: d
Second last character: l
Characters from 0th to 4th index: Hello
And, so on...
Program:
Output
str: Hello world str[0]: H str[1]: e str[-1]: d str[-2]: l str[0:5]: Hello str[2,-2]: llo wor str: H e l l o w o r l dneed an explanation for this answer? contact us directly to get an explanation for this answer