
String manipulation is an essential part of working with strings in Python. Below are some common string manipulations we can perform:
String Formatting
We can format strings using f-strings
(available in Python 3.6+), .format()
, or the %
operator.
name = "John"
age = 25
formatted_string = f"My name is {name} and I am {age} years old."
# Output: "My name is John and I am 25 years old."
formatted_string2 = "My name is {} and I am {} years old.".format(name, age)
# Output: "My name is John and I am 25 years old."
Checking String Case
(isupper()
, islower()
)
my_string = "HELLO"
is_upper = my_string.isupper()
# Output: True
my_string = "hello"
is_lower = my_string.islower()
# Output: True
Joining a List of Strings
(join()
)
words = ["Hello", "World", "Python"]
joined_string = " ".join(words)
# Output: "Hello World Python"
Testing for String Properties
(isalnum()
, isalpha()
, isdigit()
, etc.)
my_string = "Hello123"
is_alnum = my_string.isalnum()
# Output: True (contains letters and digits)
alpha_string = "Hello"
is_alpha = alpha_string.isalpha()
# Output: True (only letters)
digit_string = "12345"
is_digit = digit_string.isdigit()
# Output: True (only digits)
Happy Coding and Stay Tuned 🙂
Kind is always cool !!!
Share knowledge to gain knowledge !!!!
Be kind and treat people with respect !!!
If you find my blog helpful, then please subscribe, claps and follow to support 🙂

Top 5 Wearable Devices to Track Your Fitness and Health
In today’s…
Top System Design Interview-Design a Social Media Feed System (2025 Edition)
Overview A…
Design a URL Shortening Service
Overview We’ll…
Top 10 System Design Interview Questions (2025 Edition)
1. Design…
Top 50 Cloud Monitoring Interview Questions with Answers (2025 Edition)
1. What…
Top 50 Monitoring Tools Interview Questions with Answers
1. What…