Python String
1. Creating Strings
single_quote = 'Hello'
double_quote = "World"
multi_line = """This is
a multi-line
string"""
print(single_quote)
print(double_quote)
print(multi_line)Strings can be defined using single, double, or triple quotes.
2. Accessing String Characters (Indexing)
text = "Python"
print(text[0]) # P
print(text[-1]) # nStrings support positive and negative indexing.
3. String Slicing
Extracts substrings without modifying the original string.
4. String Immutability
Strings cannot be changed once created.
5. String Concatenation and Repetition
Used to combine or duplicate strings.
6. String Length and Membership
Performs validation and search checks.
7. Common String Methods
Used for formatting and transformation.
8. Splitting and Joining Strings
Essential for text processing and parsing.
9. String Formatting
Dynamic and readable string construction techniques.
10. Iterating Through a String
Strings are iterable character by character.
Last updated