String Methods Flashcards
Give an example of Python code that employs a string method
x=”yesss”
x.islower()
this would return True because “yesss” is all lowercase
can also do “yesss”.islower()
Returns True if the string contains only alphabetic letters or digits and is at least one character in length. Returns False otherwise.
isalnum()
Return True if the string contains only alphabetic letters and is at least one character in length. Returns False otherwise.
isalpha()
Returns True if the string contains only numeric digits and is at least one character in length. Returns False otherwise.
isdigit()
Returns True if all the string contains only numeric digits and is at least one character in length. Returns False otherwise.
isdigit()
Returns True if all of the alphabetic letters in the string are lowercase, and the string contains at least one alphabetic letter. Returns False otherwise.
islower()
Returns True if the string contains only whitespace characters and is at least one character in length. Returns False otherwise. (Whitespace characters are spaces, newlines \n, and tabs \t)
isspace()
Returns True if all of the alphabetic letters in the string are uppercase, and the string contains at least one alphabetic letter. Returns False otherwise.
isupper()
Returns a copy of the string with all alphabetic letters converted to lowercase. Any character that is already lowercase, or is not an alphabetic letter, is unchanged.
lower()
Returns a copy of the string with all leading whitespace characters removed. Leading whitespace characters are spaces, newlines (\n), and tabs (\t) that appear at the beginning of the string.
lstrip()
The char argument is a string containing a character. Returns a copy of the string with all instances of char that appear at the beginning of the string removed.
lstrip(char)
Returns a copy of the string with all trailing whitespace characters removed. Trailing whitespace characters are spaces, newlines (\n), and tabs (\t) that appear at the end of the string.
rstrip()
The char argument is a string containing a character. The method returns a copy of the string with all instances of char that appear at the end of the string removed.
rstrip(char)
Returns a copy of the string with all leading and trailing whitespace characters removed.
strip()
Returns a copy of the string with all instances of char that appear at the beginning and the end of the string removed.
strip(char)