Integer Check

Sat 17 May 2025

title: "Integer Check" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


content = "23"
content
'23'
isinstance(content, int)
False
type(content)
str
content.isdigit()
True
text = "one 2 three 4 five 6 seven 8 nine 10"
for x in text.split(" "):
    print(x, "==>", x.isdigit())
one ==> False
2 ==> True
three ==> False
4 ==> True
five ==> False
6 ==> True
seven ==> False
8 ==> True
nine ==> False
10 ==> True


Score: 5

Category: basics