Concepts
1. Classification Methods
These methods are used to check the characteristics of individual characters in a string.
1.1 Isalpha
Syntax:
Gives
Example 1:
Code
Output
Example 2:
Code
Output
1.2 Isdecimal
Syntax:
Gives
Example 1:
Code
Output
Example 2:
Code
Output
1.3 Islower
Syntax:
Gives
Example 1:
Code
Output
Example 2:
Code
Output
1.4 Isupper
Syntax:
Gives
Example 1:
Code
Output
Example 2:
Code
Output
1.5 Isalnum
Syntax:
Gives
Example 1:
Code
Output
Example 2:
Code
Output
Example 3:
Code
Output
2. Case Conversion Methods
These methods are used to change the case of a string.
2.1 Capitalize
Syntax:
Gives a new string after converting the first letter in the string to uppercase and all other letters to lowercase.
Code
Output
2.2 Title
Syntax:
Gives a new string after converting the first letter of every word to uppercase.
If a word contains a number or a special character, the first letter after that is converted to uppercase.
Example 1:
Code
Output
Example 2:
Code
Output
2.3 Swapcase
Syntax:
Gives a new string after converting the uppercase letters to lowercase and vice-versa.
Code
Output
3. Counting and Searching Methods
These methods are used to count the occurrences of a substring in a string and to find the position of a substring in a string.
3.1 Count
Syntax:
Here, the
The
If
Example 1:
Code
Output
Example 2:
Code
Output
3.2 Index
Syntax:
Here, the
The
It results in an error if the specified string
The
Example 1:
Code
Output
Example 2:
Code
Output
Example 3:
Code
Output
3.3 rIndex
Syntax:
Here, the
The
It results in an error if the specified string
The
Example 1:
Code
Output
Example 2:
Code
Output
Example 3:
Code
Output
3.4 Find
Syntax:
Here, the
The
If the specified string
The
It works similarly to the
Example 1:
Code
Output
Example 2:
Code
Output
Example 3:
Code
Output
3.5 rFind
Syntax:
Here, the
The
If the specified string
The
It works similarly to the
Example 1:
Code
Output
Example 2:
Code
Output
Example 3: