Tsallaka zuwa abun ciki
Justice Tech School

Checking and Cleaning Strings

isdigit, isalpha, isalnum, isspace and islower test content. Combine with translate or replace to clean text.

Example
for t in ["123", "abc", "a1", " "]:
    print(repr(t), t.isdigit(), t.isalpha(), t.isalnum(), t.isspace())

Result

'123' True False True False
'abc' False True True False
'a1' False False True False
' ' False False False True

Exercise

Digits only.

"12".()

Quiz Test

What does "a1".isalpha() return?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.