string module functions Flashcards
replace()
replace(): method replaces a specified phrase with another specified phrase
find()
find(): finds the first occurrence of the specified value
lower()
lower(): Lowercases the alphabetical values in a string
upper()
upper(): Uppercases the alphabetical values in a string
strip()
strip(): removes any leading, and trailing whitespaces
capitalize()
capitalize(): Returns a copy of the string with its first character capitalized.
title()
title(): Returns a titlecased version of the string, where words start with an uppercase character and the remaining characters are lowercase.
center(width[, fillchar])
center(width[, fillchar]): Returns a centered string of a specified width, optionally padded with a fill character.
count(sub[, start[, end]])
count(sub[, start[, end]]): Returns the number of occurrences of a substring in the given range.
endswith(suffix[, start[, end]])
endswith(suffix[, start[, end]]): Returns True if the string ends with the specified suffix; otherwise, returns False.
join(iterable)
join(iterable): links elements of an iterable (e.g., a list) into a single string, with the string as a separator.
split([sep[, maxsplit]])
split([sep[, maxsplit]]): Splits a string into a list of substrings based on a specified separator.
strip([chars])
strip([chars]): Returns a copy of the string with leading and trailing characters removed (whitespace by default, or characters specified in chars).
replace(old, new[, count])
replace(old, new[, count]): Replaces occurrences of a specified substring with another substring.
startswith(prefix[, start[, end]])
startswith(prefix[, start[, end]]): Returns True if the string starts with the specified prefix; otherwise, returns False.