Professional Documents
Culture Documents
Strings
A string is a sequence of characters.
Character could be a letter, digit, white space or any special symbols.
Python does not support character data type.
A single character also works as a string. Python supports writing the
string within a single quote(‘ ‘) and a double quote(“ “).
Index: Individual character in a string are accessed using subscript([])
operator. Index of first character is 0 and last character is n-1
Example
Indexing in Strings
Positive and negative indexing
String Membership Test
We can test if a sub string exists within a string or
not, using the keyword in
Concatenation, Appending and
Multiplication of Strings
Joining of two or more strings into a single one is called concatenation
(using + operator) Append mean to add something at the end.
To append a string using “+=“ operator
To repeat a string in n no.of times using ‘*’ operator.
Strings are immutable
Strings are immutable (can’t change using index)