1/41
Complete set of vocabulary flashcards defining built-in Python string methods for Chapter 1: All Python String.
str.capitalize()
Converts the first character of the string to uppercase and converts all remaining characters to lowercase.
str.casefold()
Converts the string to lowercase using an aggressive algorithm suitable for caseless matching and comparisons.
str.center(width, fillchar)
Returns a centered string of length equal to width, padded with the specified fillchar (default is an ASCII space).
str.count(sub, start, end)
Returns the number of non-overlapping occurrences of a specified substring within the optional slice range [start, end].
str.encode(encoding, errors)
Returns an encoded version of the string as a bytes object using the specified character encoding.
str.endswith(suffix, start, end)
Returns True if the string ends with the specified suffix, otherwise returns False.
str.expandtabs(tabsize)
Returns a copy of the string where all tab characters are replaced with one or more spaces, depending on the specified tabsize (default is 8).
str.find(sub, start, end)
Returns the lowest index where the substring sub is found within the string, or −1 if the substring is not found.
str.format(*args, **kwargs)
Formats the string by replacing curly brace placeholders with the specified positional or keyword arguments.
str.index(sub, start, end)
Similar to find(), but raises a ValueError if the specified substring is not found.
str.isalnum()
Returns True if all characters in the string are alphanumeric (letters or numbers) and there is at least one character.
str.isalpha()
Returns True if all characters in the string are alphabetic and there is at least one character.
str.isascii()
Returns True if the string is empty or all characters in the string are ASCII characters.
str.isdecimal()
Returns True if all characters in the string are decimal characters and there is at least one character.
str.isdigit()
Returns True if all characters in the string are digits (including superscripts and subscripts) and there is at least one character.
str.isidentifier()
Returns True if the string is a valid Python identifier according to language definitions.
str.islower()
Returns True if all cased characters in the string are lowercase and there is at least one cased character.
str.isnumeric()
Returns True if all characters in the string are numeric characters (such as fractions or Roman numerals) and there is at least one character.
str.isprintable()
Returns True if all characters in the string are printable or the string is empty.
str.isspace()
Returns True if all characters in the string are whitespace characters and there is at least one character.
str.istitle()
Returns True if the string follows title casing rules (each word starts with an uppercase character followed by lowercase characters).
str.isupper()
Returns True if all cased characters in the string are uppercase and there is at least one cased character.
str.join(iterable)
Concatenates an iterable of strings into one string using the calling string as the delimiter.
str.ljust(width, fillchar)
Returns a left-justified string of specified width, padded on the right with fillchar (default is an ASCII space).
str.lower()
Returns a copy of the string with all cased characters converted to lowercase.
str.lstrip(chars)
Returns a copy of the string with leading whitespace (or specified leading characters in chars) removed.
str.partition(sep)
Splits the string at the first occurrence of sep and returns a 3-tuple containing the part before sep, sep itself, and the part after sep.
str.replace(old, new, count)
Returns a copy of the string with occurrences of old replaced by new, up to the optional count limit.
str.rfind(sub, start, end)
Returns the highest index where the substring sub is found, or −1 if it is not found.
str.rindex(sub, start, end)
Similar to rfind(), but raises a ValueError if the specified substring is not found.
str.rjust(width, fillchar)
Returns a right-justified string of specified width, padded on the left with fillchar (default is an ASCII space).
str.rpartition(sep)
Splits the string at the last occurrence of sep and returns a 3-tuple containing the part before sep, sep itself, and the part after sep.
str.rsplit(sep, maxsplit)
Splits the string from the right into a list of strings using sep as the delimiter, up to maxsplit times.
str.rstrip(chars)
Returns a copy of the string with trailing whitespace (or specified trailing characters in chars) removed.
str.split(sep, maxsplit)
Splits the string from the left into a list of substrings using sep as the delimiter, up to maxsplit times.
str.splitlines(keepends)
Splits the string at line breaks and returns a list of lines, retaining line breaks if keepends is True.
str.startswith(prefix, start, end)
Returns True if the string starts with the specified prefix, otherwise returns False.
str.strip(chars)
Returns a copy of the string with both leading and trailing whitespace (or specified characters in chars) removed.
str.swapcase()
Returns a copy of the string with uppercase characters converted to lowercase and lowercase characters converted to uppercase.
str.title()
Returns a titlecased version of the string where words start with an uppercase character and remaining characters are lowercase.
str.upper()
Returns a copy of the string with all cased characters converted to uppercase.
str.zfill(width)
Pads the string with ASCII '0' digits on the left until it reaches the specified width; correctly handles an initial sign prefix.