Extended Slicing
Syntax:
Step determines the increment between each index for slicing.
Code
Output
Methods
Python has a set of built-in reusable utilities. They simplify the most commonly performed operations are:
String Methods
- isdigit()
- strip()
- lower()
- upper()
- startswith()
- endswith()
- replace()and more...
Isdigit
Syntax:
Gives
Code
Output
Strip
Syntax:
Removes all the leading and trailing spaces from a string.
Code
Output
Strip - Specific characters
Syntax:
We can also specify characters that need to be removed.
Code
Output
Strip - Multiple Characters
Removes all spaces, comma(,) and full stop(.) that lead or trail the string.
Code
Output
Replace
Syntax:
Gives a new string after replacing all the occurrences of the old substring with the new substring.
Code
Output
Startswith
Syntax:
Gives
Code
Output
Endswith
Syntax:
Gives
Code
Output
Upper
Syntax:
Gives a new string by converting each character of the given string to uppercase.
Code
Output
Lower
Syntax:
Gives a new string by converting each character of the given string to lowercase.