Sunday, March 29, 2026

Python Tutorial for Beginners: String Methods in Python

Welcome Quillix Python Tutorial. In previous chapter, we have covered some Python string methods. Now we will learn about other string methods that help us to modify and write program.

banner string method

String Methods or Functions

Replace()

Using this method, user can replace character or word with another.

Syntax: string.replace(old, new)

name = "Quillix Blogspot"
new_name = name.replace("Blogspot", "Python Tutorial")
print(new_name)         #Output: Quillix Python Tutorial

img1

Split()

It allows coder to split string in list. By default, it use space to split string but we can also mention specific character to split data.

my_text = "How are you?"
result = my_text.split()
print(result)

img2

Find()

This method returns the index of the string's position. If it does not find the word, it outputs -1.

str = "Today is my birthday"
print(str.find("birthday"))

imag3

Count()

Use this method to count the word in string.
text = "Python Python Quillix"
print(text.count("Python"))

img4

Startswith()

If you want to check the string starting word then we can use startswith() method.

text = "Python Programming"
print(text.startswith("Python"))

img5

Endswith()

This method helps you to find end word true or false.

text = "Python Programming"
print(text.endswith("Python"))

img6

Strip()

We are already learn this method It removes space start and end.

myText = "  Python Programming  "
print(myText.strip())

img7

Upper() and Lower()

myText1 = "python programming"
print(myText1.upper())
myText2 = "PYTHON"
print(myText2.lower())
img8

Join()

Joins elements of a list into a string.

joinWord = ("Quillix", "Python", "Tutorial")
print(" ".join(joinWord))

img9

Capitalize()

Make first letter capital (upper case).
myText4 = ("Python is easy to learn")
print(myText4.capitalize())

Final Thoughts

We have completed the String chapter in Python. The next chapter will cover the input() function. Read this tutorial and practice as much as you can. Also share with others who wants to learn python in simple word.


Practice Your Code Below

🐍 Python Playground

No comments:

Post a Comment

Featured Post

What Is Artificial Intelligence (AI) ? – A Step-by-Step Guide

AI (Artificial Intelligence) is a rapidly growing technology in today's world, and you can see it whenever you browse or search for any ...