A method is a function associated with a particular type. Call it by placing the value first, followed by a dot, then parentheses containing any arguments. section 4.3.4
Cleaning a phone number
The replace() method removes selected characters from a string: phone_number.replace('(', '') replaces each opening parenthesis with nothing. Applying it again removes closing parentheses and hyphens. Copilot’s Explain feature can clarify unfamiliar methods. section 4.3.4
>>> 'abc'.isupper() #1 False >>> 'Abc'.isupper() False >>> 'ABC'.isupper() True >>> 'abc'.isdigit() #2 False #2 >>> '345bc'.isdigit() #2 False #2 >>> '345'.isdigit() #2 True #2 >>> 'abc6'.isalnum() #3 True #3 >>> 'abc def'.isalnum() #3 False #3 >>> 'abcdef#'.isalnum() #3 False #3
Try string methods that test capitalization, digits, and alphanumeric content, then compare their Boolean results. section 4.3.4
Common method roles include:
- Converting strings between lowercase and uppercase. section 4.3.4
- Searching, formatting, or replacing parts of strings. section 4.3.4



















