Back to Python Notes
Topic #19

Modify Strings

Strings are immutable, but a rich set of methods lets you transform them into new values. Learn upper, lower, strip, replace and friends.


Python has a set of built-in methods that you can use on strings.


Upper Case

Example

a = "Hello, World!"
print(a.upper())

Lower Case

Example

a = "Hello, World!"
print(a.lower())

Remove Whitespace

Whitespace is the space before and/or after the actual text, and very often you want to remove this space.

Example

a = " Hello, World! "
print(a.strip()) # returns "Hello, World!"

Replace String

Example

a = "Hello, World!"
print(a.replace("H", "J"))

Split String

The split() method returns a list where the text between the specified separator becomes the list items.

Example

a = "Hello, World!"
print(a.split(",")) #
  returns ['Hello', ' World!']

Learn more about Lists in our Python Lists chapter.


String Methods

Learn more about String Methods with our String Methods Reference

Want to go beyond the notes?

Join Coding Now Tech Institute's Python course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Modify Strings – FAQs

Quick answers about learning Modify Strings in Python.

This free note from Coding Now Tech Institute explains Modify Strings in Python — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Python topic on Coding Now Tech Institute, including Modify Strings, is 100% free with no signup required.
With focused practice, most students grasp Modify Strings in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now