What is String ?
String is an datatype in python. It is represented as 'str' in python.
String is enclosed with single(' ') or double quotes("") , if we want to print multiline string we can use triple quotes(""" """).
String is collection of characters ,characters can be anything , includes alphabets ,special characters and numbers.
String is immutability.(nce created, a string cannot be modified in place; methods like .upper() or .replace() return a new string object).
In python there positive and negative indexing , positive index start from zero (lest to right) and negative index start from -1 (right to letft).
text = "H e l l o" 0 1 2 3 4 ----> ( positive indexing ) - 5 - 4 - 3 - 2 - 1 ----> ( Negative indexing )
Enter fullscreen mode
Exit fullscreen mode
why string is required ?
to store, display, and manipulate text—such as words, sentences, symbols, and numbers treated as characters rather than math values.
Common Uses of Strings
Displaying text: Showing labels, menus, error messages, and…