What are Strings in Python

It’s a Sequence, a Sequence of Characters Can access the characters using the braket operator >>> fruit = 'banana' >>> letter = fruit[1] >>> print(letter) a You get that fruit[1] is a, the second letter in the string. Remeber counting starts from 0 in Python. the number inside the bracket is called the index. Indeces can be negative. But index $\in [-length+1, length -1]$. len is the built-in function which gives the length of a string....

March 7, 2021 · 4 min · Harsh Kumar