python_string_functions_final
python_string_functions_final
center() Centers string with padding str.center(width, fillchar) 'hi'.center(10, '*') -> '****hi****'
endswith() Checks if string ends with suffix str.endswith(suffix) 'hello'.endswith('lo') -> True
find() Finds substring index (-1 if not found) str.find(sub) 'hello'.find('e') -> 1
isdecimal() Checks if all chars are decimal str.isdecimal() '123'.isdecimal() -> True
isdigit() Checks if all chars are digits str.isdigit() '123'.isdigit() -> True
isnumeric() Checks if all chars are numeric str.isnumeric() '1/3'.isnumeric() -> True
islower() Checks if all chars are lowercase str.islower() 'hello'.islower() -> True
isupper() Checks if all chars are uppercase str.isupper() 'HELLO'.isupper() -> True
isspace() Checks if all chars are whitespace str.isspace() ' '.isspace() -> True
ljust() Left-aligns string with padding str.ljust(width, fillchar) 'hi'.ljust(5, '-') -> 'hi---'
split() Splits string into list str.split(sep) 'a,b,c'.split(',') -> ['a', 'b', 'c']
startswith() Checks if string starts with prefix str.startswith(prefix) 'hello'.startswith('he') -> True
strip() Removes leading and trailing whitespace str.strip(chars) ' hello '.strip() -> 'hello'
title() Converts string to title case str.title() 'hello world'.title() -> 'Hello World'