Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. String manipulation in python
  5. Accessing string in python

Accessing string in python

Python strings are enclosed in quotes of any type- single quotation, double quotation and triple quotation. An empty string is a string that has 0 characters(i.e., it is just a pair of quotation marks).

e.g.,

s="Python"
print(s)
a=''
print(a)
Output- 
Python

Strings are sequence of characters, where each character has a unique position-id/index.

The index of the string starts from 0. We can access characters of the string using its index number. The indexes of a string from 0 to (length-1) in forward direction and -1, -2, -3, …., -length in backward direction.

e.g.,

s="pythonpoint"
print(s[5])
a="Python"
print(s[-1])
Output-
n
n

This is all about accessing string character in python.

Was this article helpful to you? Yes No

How can we help?