isdigit()
String methods that check what kind of characters a string contains, such as isdigit for only digits.
In more detail
"123".isdigit() is True but "-5".isdigit() and "".isdigit() are False, so checking whether input is a valid number needs more than one test. These checks are how the course validates input before converting it.
Related terms
- string method — A method that belongs to strings, such as upper, lower, count, find, replace, split, strip, startswith or join.
- type conversion — Turning a value of one type into another, such as the string "23" into the integer 23.
- input validation — Checking that data from a user, file or caller is acceptable before using it, and rejecting or asking again if not.
Taught in
- More String Methods — Hands-on Python: Complete Video Course & Book
- Strings: Escapes, Slices And Methods — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- String Methods The Exam Picks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep