The string is defined as an array of characters, though python does not have a character data type. A string value is defined within a double-quote or a single quote sign or even a triple single/double quotation sign. such as
name="Elia Haider" name='Elia Haider' name='''Elia Haider'''
we can also have a multi-line string which is used within the triple double/single quotation sign.
sentence=""" Hello My name is Elia Haider. I was born on 26 June 2019. """ print(sentence)
Strings are arrays
As strings in python are arrays of characters and we can access each cell of an array using its index/subscript value.
name="Elia Haider" print(name) print(name) print(name[-1])
we can use negative index numbers which are counted from the reverse side of the string.
Support us by sharing this post