CBSE 2026 results are out, Mukul scored a perfect 100/100 in Computer ScienceSee all toppers →

KwickAcademy Python · 7 min · free

Built-in String Methods

7 min5 KwickClipsFull text belowFree
Next lesson →Kajal Ma'am (MCA), teaching since 2004Remembered in this browser

Learn Python built-in string methods for CBSE Class 11: case, count, find, index, is-methods, strip, replace, split, join, partition. A method is a ready-made tool that belongs to a value, used with a dot, like name.upper(); it returns a new value.

Follows the syllabus of: CBSE Class 11 Computer Science (083), CBSE Class 11 Computer Science Essentials (083), CBSE Class 9 Artificial Intelligence (417)

On screen in this lesson

What is a string method?

String: text inside quotes
Method: a ready-made tool for a value
Written with a dot: name.upper()
Returns a new value; the string is unchanged

find() vs index()

CallFoundNot found
find("n")gives 2gives -1
index("n")gives 2ValueError

The is-methods

MethodTrue when all areTrue example
isalnum()letters or digits"Class9"
isalpha()letters"Riya"
isdigit()digits"2026"
islower()letters all small"class 9"
isupper()letters all capital"RIYA"
isspace()spaces, tabs" "

Quick recap

Case: capitalize, title, lower, upper
Search: count, find, index, startswith, endswith
Check: is-methods give True or False
Clean and cut: strip, replace, split, join, partition
Methods return new values; strings never change

Quick answers

What is the difference between find() and index()?

When the text is missing, find() gives -1, but index() stops with a ValueError.

Why is "Riya Shah".isalpha() False?

The space is not a letter, so isalpha() gives False.

KwickClips from this lesson

Short clips, one idea each. Good for revision the night before.

The full lesson, in text

Hello students, welcome to Kwickprep. How can a program check if a name has only letters, or clean extra spaces from a form? Python has ready-made tools for this, called string methods. Today we will learn the most useful ones, and three exam programs that use them.

First, some new words. A string is text written inside quotes. A method is a ready-made tool that belongs to a value, like a string. We use it with a dot, then the method name, then round brackets. Strings can never be changed, so a method gives back a new value and the old string stays the same.

The len function counts characters, and the space counts too, so it gives nine. Len is a function, not a method, so it has no dot. Capitalize makes only the first letter capital, and all other letters small. Title makes the first letter of every word capital. Lower makes every letter small. Upper makes every letter capital.

Count tells how many times some text appears, so the letter a appears three times in banana. Find gives the index, which is the position number, of the first match. Positions start at zero, so the first letter n is at two. If the text is not there, find gives minus one. Pause and predict: what does find give for the letter b? Zero, because b is at the very first position. Zero means found, not missing.

Index looks just like find, with one big difference. When the text is found, find gives its position. Index also gives the same position. But when the text is missing, find calmly gives minus one, while index stops the program with a value error.

Startswith checks the beginning of a string, and endswith checks the end. The answer is always True or False. New Delhi starts with New, so True. It ends with the text hi, so True. But it does not start with new in small letters, so False. Capital and small letters are different in Python.

Methods that start with is answer a True or False question about the characters. Is alnum is True when all characters are letters or digits. Is alpha needs only letters. Is digit needs only digits. Is lower needs every letter to be small, and it ignores digits and spaces, so class nine in small letters is True. Is upper needs every letter to be a capital. Is space needs only blank characters, like spaces or tabs.

Exams love these traps, and all four answers are False. Riya Shah has a space, and a space is not a letter. Twelve point five has a dot, and a dot is not a digit. Class nine also has a space in the middle. And an empty string, with nothing inside the quotes, gives False for every is-method.

Users often type extra spaces in a form. The string here has two spaces on each side. We print square brackets around it, so you can see the spaces. Strip removes spaces from both ends. Lstrip, the left strip, removes them only from the left. Rstrip, the right strip, removes them only from the right.

Replace swaps every match of old text with new text, so tea becomes chai. Split breaks a string into a list of words. A list is many values inside square brackets. With nothing inside the brackets, split cuts at spaces. If you give it a comma, it cuts at every comma instead.

Join is the opposite of split. It glues a list of strings together, with the string before the dot in between. So we get red, dash, green, dash, blue. Partition cuts a string at the first match into exactly three parts. We get the part before, the separator itself, and the part after. The round brackets show these three parts are kept together, as a tuple.

Now three programs. First, count the vowels in Incredible India. We use lower first, so capital I is also counted. The loop takes one character at a time, called ch. The word in checks, is ch one of a, e, i, o, u? Each time it is, vowels goes up by one. The answer is seven.

Second, a palindrome is a word that reads the same backwards, like Malayalam. We make it lower case, so capital M matches small m. The slice with a step of minus one reverses the string. Double equals asks, are the two strings equal? They are, so it prints Malayalam is a palindrome.

Third, count the words in a sentence. This line has extra spaces at the start, the end, and in the middle. Split with nothing inside the brackets ignores all extra spaces. So we get a clean list of five words. Len of that list gives the word count, five.

Let us revise what we learned today. Capitalize, title, lower and upper change the case of letters. Count, find, index, startswith and endswith search inside a string. The is-methods check every character and give True or False. Strip, replace, split, join and partition clean and cut strings. And every method returns a new value, because strings never change.

Courses that teach this

CourseUnit
CBSE Class 9 Artificial Intelligence (417)Part B - Unit 5: Introduction to Python
CBSE Class 11 Computer Science (083)Computational Thinking and Programming - I
CBSE Class 11 Computer Science Essentials (083)Computational Thinking and Programming - I
Programming All levels PythonStrings

Voice-over in this lesson is AI-generated. The script is written and checked by Kajal Ma'am. Boards can revise a syllabus mid-year, so confirm anything you plan around against the official board circular. Keep your passwords, OTPs and ID numbers to yourself — we never ask for them. To reach Kajal Ma'am, use the WhatsApp button; sharing your number there is how we call you back.

Free to watch, no sign-up. Live classes with Kajal Ma'am are the paid course; these lessons stay free either way.

Want a plan that actually fits your board dates?

Ask Kajal Ma'am directly, 20+ years teaching computer science. Free demo class first, no payment.

Talk to Kajal Ma'am on WhatsApp

Or see the Class 12 Computer Science course →

Studying outside India?

We coach CBSE, IGCSE & international students across the globe, one-to-one, in your local time zone.

Visit International →