January 2019
Beginner
318 pages
8h 23m
English
Like numbers, strings are also one of the data structures in Python. Python can manipulate strings. Strings can be expressed as follows:
See the following example:
>>> 'Hello Python''Hello Python'>>> "Hello Python"'Hello Python'
A string is a set of characters. We can access the characters one at a time, as follows:
>>> city = 'delhi'>>> letter = city[1]>>> letter = city[-3]
In the second statement, we are selecting the character number 1 from city and assigning it to letter. The number in those square brackets is an index. The index indicates which character you want to access. It starts from 0. So, in the preceding example, when you will execute letter = city[1] ...
Read now
Unlock full access