Posts

Showing posts with the label Basic String Methods

Python - Basic String Methods

Image
Let’s take a look at some of the fundamental string methods that can be used in your application: isalpha (): returns True if a string only consists of alphabetic characters. islower(): returns True if a string has only lowercase characters. isupper(): returns True if all uppercase characters in the string. isdigit(): returns True if all characters in the string are digits. isnumeric(): returns True if a string is a integer. startswith(str): returns True if the string starts with the substring str. endswith(str): returns True if the string ends with the substring str. lower(): returns a string where all characters are lower case. upper(): returns a string where all characters are upper case. title(): used to Uppercase the first character in each word and Lowercase the following characters and returns a new string. capitalize(): only the first letter in the beginning of the string is capitalized. lstrip(): removes leading spaces from a string. rstrip(): removes trailing spaces from a st