Python functions
Built-in functions, string and list methods, dictionary and set operations. Every entry with a LIVE pill has a live in-browser demo.
Methods on the built-in string type. Immutable — every method returns a new string.
LIVE
str.capitalize
capitalize()
Return a copy with the first character titlecased and the rest lowercased.
LIVEstr.find
find(sub, start=0, end=len(s))
Return the lowest index of a substring, or -1 if absent.
LIVEstr.join
join(iterable)
Concatenate an iterable of strings with this string as the separator.
LIVEstr.lower
lower()
Return a copy of the string with all cased characters lowercased.
LIVEstr.replace
replace(old, new, count=-1)
Return a copy with all occurrences of old replaced by new.
LIVEstr.split
split(sep=None, maxsplit=-1)
Break a string into a list of substrings on a delimiter.
LIVEstr.startswith
startswith(prefix, start=0, end=len(s))
Test whether the string begins with a prefix.
LIVEstr.count
count(sub, start=0, end=len(s))
Count non-overlapping occurrences of a substring.
LIVEstr.strip
strip(chars=None)
Return a copy with leading and trailing characters removed.
LIVEstr.upper
upper()
Return a copy of the string with all cased characters uppercased.