You would need to remove the numbers from the list as you are comparing each character to all the digits at once i.e "1" == "0123456789" , you also need to check every char before returning True:

def is_dig(s):
    numbers = "0123456789"  # single iterable of the numbers
    for i in s:
        if i not in numbers:
            return False
    return bool(s) # return outside the loop also catching empty string

A more efficient approach would be to use the ord and all:

def is_dig(s):
    return len(s) > 0 and all(48 <= ord(ch) <= 57 for ch in s)

The ord of "0" is 48 and the ord of "9" is 57 so if the ord of the char falls in that range then you have a digit, if not all will short circuit and return False.

Using the ord without all and following your own logic would look something like:

def is_dig(s):
    if not s: # empty string
        return False
    for ch in s:
        if not 48 <= ord(ch) <= 57:
            return False
    return True
Answer from Padraic Cunningham on Stack Overflow
🌐
W3Schools
w3schools.com › Python › ref_string_isdigit.asp
Python String isdigit() Method
Python Examples Python Compiler ... Python Interview Q&A Python Training ... The isdigit() method returns True if all the characters are digits, otherwise False....
🌐
Python
docs.python.org › 3 › builtins › stdtypes.html
Built-in Types — Python 3.14.7 documentation
>>> '0123456789'.isdigit() True >>> '٠١٢٣٤٥٦٧٨٩'.isdigit() # Arabic-Indic digits zero to nine True >>> '⅕'.isdigit() # Vulgar fraction one fifth False >>> '²'.isdecimal(), '²'.isdigit(), '²'.isnumeric() (False, True, True)
Discussions

creating a function like isdigit() in python - Stack Overflow
Please don't give me the answer just point me in the right direction, thank you. Also, I need to do this without isdigit(). I am trying to create a program that checks all the characters of a stri... More on stackoverflow.com
🌐 stackoverflow.com
For single-char strings, Strings' .isdigit() method is about 7% slower than simply checking ```if string in "0123456789"```. Possible bug?
This susprised me because I assumed that the algorithm behind STRING.isdigit() is essentially a for loop that goes through each character of the string to check if it's a member of "0123456789". That is incorrect, isdigit() checks against the entire "Decimal Digit" Unicode category (Nd) which has hundreds of code points in it. So 7% slower is not bad. To be fair that's a common mistake, its behavior is really not what it looks like at first glance. More on reddit.com
🌐 r/Python
16
2
June 17, 2020
How To use isdigit in python
Hello, today i wanted to make a tkinter program and i made an entry about age the i only wanted the entry to get int numebrs for age but i did anything but it didnt work i asked someone for help and she said that i need to use isdigit but she didnt say how to use it. i just want to know how ... More on discuss.python.org
🌐 discuss.python.org
13
0
August 18, 2024
What's the difference between str.isdigit(), isnumeric() and ...
These are some of the least useful ... of the Python API. We really need an isfloat and the poorly named isdecimal and isnumeric are easy confused with these. 2021-08-29T16:44:03.63Z+00:00 ... Good answer but it would have helped slightly in the reading if you listed them in logical order: isdecimal - isdigit - isnumeric ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Educative
educative.io › answers › what-is-the-isdigit-function-in-python
What is the isdigit() function in Python?
The isdigit() method checks if a string contains only numeric characters or not. It returns True if the string is entirely numeric and non-empty, otherwise False. It does not recognize currency values, fractions, or Roman numerals as numeric digits.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-string-isdigit-method
Python String isdigit() Method - GeeksforGeeks
May 1, 2025 - The isdigit() method is a built-in Python function that checks if all characters in a string are digits. This method returns True if each character in the string is a numeric digit (0-9) and False otherwise.
🌐
DEV Community
dev.to › kiani0x01 › python-isdigit-vs-isnumeric-2jcj
Python isdigit vs isnumeric - DEV Community
August 5, 2025 - Use isdigit() for a strict check of decimal digits, and isnumeric() when you need to catch a wider range of Unicode numerals—fractions, superscripts, or other numeric symbols. Always test edge cases against your data set, and consider performance ...
🌐
LernerPython
lernerpython.com › home › lernerpython blog › python’s str.isdigit vs. str.isnumeric
Python's str.isdigit vs. str.isnumeric - LernerPython
February 17, 2019 - Bottom line: str.isdigit returns True only for the digits 0-9 (plus superscripts like ‘\u00b2’), while str.isnumeric also returns True for numeric characters from other writing systems, such as the Chinese ‘\u4e00\u4e8c\u4e09’. A third ...
Find elsewhere
🌐
Codecademy
codecademy.com › docs › python › strings › .isdigit()
Python | Strings | .isdigit() | Codecademy
April 25, 2025 - The .isdigit() method under the string class checks if all the elements in the string are digits; applicable elements also include special cases like superscript digits (¹, ², ³, etc.).
🌐
YouTube
youtube.com › watch
String isdigit() Method | Python Tutorial - YouTube
How to use the string isdigit() method in Python to check if a string contains only digits, including a discussion of potentially unclear cases such as space...
Published: January 6, 2023
🌐
Medium
medium.com › @RedBeret › pythons-isdigit-and-beyond-making-data-validation-easy-b6703821680b
Python’s isdigit and Beyond: Making Data Validation Easy | by RedBeret (Steven) | Medium
January 5, 2024 - This project not only leverages ... tools. Role and Importance: The isdigit() method in Python is essential for ensuring that a string is composed only of digits....
🌐
Reddit
reddit.com › r/python › for single-char strings, strings' .isdigit() method is about 7% slower than simply checking ```if string in "0123456789"```. possible bug?
r/Python on Reddit: For single-char strings, Strings' .isdigit() method is about 7% slower than simply checking ```if string in "0123456789"```. Possible bug?
June 17, 2020 -

I was looking to optimize a program of mine that works on very, very large text files. I was fiddling around with various algorithms that perform a certain task on said data, one part of which is to convert characters to an integer;

which, of course, first has to check whether the character is an integer in the first place.

try/except was slow for my intents and purposes, so I went with the good old-fashioned if-elif-else and ran various time-measuring tests on some 2 GB of text.

My findings:

if c.isdigit(): is about 7% slower than if c in "0123456789"

This susprised me because I assumed that the algorithm behind STRING.isdigit() is essentially a for loop that goes through each character of the string to check if it's a member of "0123456789".

And since I'm trying out both time-tests on ONE-character strings only, my expectation was that the performance times would be equal.

Well... they're not, as pointed above.

Should this be considered a bug? Clearly, c.isdigit() isn't operating as efficiently as it should.

🌐
Python.org
discuss.python.org › python help
How To use isdigit in python - Python Help - Discussions on Python.org
August 18, 2024 - Hello, today i wanted to make a tkinter program and i made an entry about age the i only wanted the entry to get int numebrs for age but i did anything but it didnt work i asked someone for help and she said that i need to use isdigit but she didnt say how to use it. i just want to know how to use isdigit from tkinter import * from tkinter import ttk from tkinter import messagebox UserData = [] # Screen Customize Screen = Tk() Screen.title("Panel") Screen.iconbitmap("icon/icon.ico") Scree...
Top answer
1 of 5
263

By definition, isdecimal()isdigit()isnumeric(). That is, if a string is decimal, then it'll also be digit and numeric.

Therefore, given a string s and test it with those three methods, there'll only be 4 types of results.

isdecimal() isdigit() isnumeric() Example
True True True "038", "੦੩੮", "038"
False True True "⁰³⁸", "🄀⒊⒏", "⓪③⑧"
False False True "↉⅛⅘", "ⅠⅢⅧ", "⑩⑬㊿", "壹貳參"
False False False "abc", "38.0", "-38"

1. Some examples of characters isdecimal()==True

(thus isdigit()==True and isnumeric()==True)

"0123456789"  DIGIT ZERO~NINE
"٠١٢٣٤٥٦٧٨٩"  ARABIC-INDIC DIGIT ZERO~NINE
"०१२३४५६७८९"  DEVANAGARI DIGIT ZERO~NINE
"০১২৩৪৫৬৭৮৯"  BENGALI DIGIT ZERO~NINE
"੦੧੨੩੪੫੬੭੮੯"  GURMUKHI DIGIT ZERO~NINE
"૦૧૨૩૪૫૬૭૮૯"  GUJARATI DIGIT ZERO~NINE
"୦୧୨୩୪୫୬୭୮୯"  ORIYA DIGIT ZERO~NINE
"௦௧௨௩௪௫௬௭௮௯"  TAMIL DIGIT ZERO~NINE
"౦౧౨౩౪౫౬౭౮౯"  TELUGU DIGIT ZERO~NINE
"೦೧೨೩೪೫೬೭೮೯"  KANNADA DIGIT ZERO~NINE
"൦൧൨൩൪൫൬൭൮൯"  MALAYALAM DIGIT ZERO~NINE
"๐๑๒๓๔๕๖๗๘๙"  THAI DIGIT ZERO~NINE
"໐໑໒໓໔໕໖໗໘໙"  LAO DIGIT ZERO~NINE
"༠༡༢༣༤༥༦༧༨༩"  TIBETAN DIGIT ZERO~NINE
"၀၁၂၃၄၅၆၇၈၉"  MYANMAR DIGIT ZERO~NINE
"០១២៣៤៥៦៧៨៩"  KHMER DIGIT ZERO~NINE
"0123456789"  FULLWIDTH DIGIT ZERO~NINE
"𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗"  MATHEMATICAL BOLD DIGIT ZERO~NINE
"𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡"  MATHEMATICAL DOUBLE-STRUCK DIGIT ZERO~NINE
"𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫"  MATHEMATICAL SANS-SERIF DIGIT ZERO~NINE
"𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵"  MATHEMATICAL SANS-SERIF BOLD DIGIT ZERO~NINE
"𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿"  MATHEMATICAL MONOSPACE DIGIT ZERO~NINE

2. Some examples of characters isdecimal()==False but isdigit()==True

(thus isnumeric()==True)

"⁰¹²³⁴⁵⁶⁷⁸⁹"  SUPERSCRIPT ZERO~NINE
"₀₁₂₃₄₅₆₇₈₉"  SUBSCRIPT ZERO~NINE
"🄀⒈⒉⒊⒋⒌⒍⒎⒏⒐"  DIGIT ZERO~NINE FULL STOP
"🄁🄂🄃🄄🄅🄆🄇🄈🄉🄊"  DIGIT ZERO~NINE COMMA
"⓪①②③④⑤⑥⑦⑧⑨"  CIRCLED DIGIT ZERO~NINE
"⓿❶❷❸❹❺❻❼❽❾"  NEGATIVE CIRCLED DIGIT ZERO~NINE
"⑴⑵⑶⑷⑸⑹⑺⑻⑼"  PARENTHESIZED DIGIT ONE~NINE
"➀➁➂➃➄➅➆➇➈"  DINGBAT CIRCLED SANS-SERIF DIGIT ONE~NINE
"⓵⓶⓷⓸⓹⓺⓻⓼⓽"  DOUBLE CIRCLED DIGIT ONE~NINE
"➊➋➌➍➎➏➐➑➒"  DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ONE~NINE
"፩፪፫፬፭፮፯፰፱"  ETHIOPIC DIGIT ONE~NINE

3. Some examples of characters isdecimal()==False and isdigit()==False but isnumeric()==True

"½⅓¼⅕⅙⅐⅛⅑⅒⅔¾⅖⅗⅘⅚⅜⅝⅞⅟↉"  VULGAR FRACTION
"৴৵৶৷৸৹"  BENGALI CURRENCY NUMERATOR
"௰௱௲"  TAMIL NUMBER TEN, ONE HUNDRED, ONE THOUSAND
"౸౹౺౻౼౽౾"  TELUGU FRACTION DIGIT
"൰൱൲൳൴൵"  MALAYALAM NUMBER, MALAYALAM FRACTION
"༳༪༫༬༭༮༯༰༱༲"  TIBETAN DIGIT HALF ZERO~NINE
"፲፳፴፵፶፷፸፹፺፻፼"  ETHIOPIC NUMBER TEN~NINETY, HUNDRED, TEN THOUSAND
"៰៱៲៳៴៵៶៷៸៹"  KHMER SYMBOL LEK ATTAK
"ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯ"  ROMAN NUMERAL
"ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿ"  SMALL ROMAN NUMERAL
"ↀↁↂↅↆ"  ROMAN NUMERAL
"⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳㉑㉒㉓㉔㉕㉖㉗㉘㉙㉚㉛㉜㉝㉞㉟㊱㊲㊳㊴㊵㊶㊷㊸㊹㊺㊻㊼㊽㊾㊿"  CIRCLED NUMBER TEN~FIFTY
"㉈㉉㉊㉋㉌㉍㉎㉏"  CIRCLED NUMBER TEN~EIGHTY ON BLACK SQUARE
"⑽⑾⑿⒀⒁⒂⒃⒄⒅⒆⒇"  PARENTHESIZED NUMBER TEN~TWENTY
"⒑⒒⒓⒔⒕⒖⒗⒘⒙⒚⒛"  NUMBER TEN~TWENTY FULL STOP
"⓫⓬⓭⓮⓯⓰⓱⓲⓳⓴"  NEGATIVE CIRCLED NUMBER ELEVEN
"⓾➉❿➓"  various styles of CIRCLED NUMBER TEN
"🄌"  DINGBAT NEGATIVE CIRCLED SANS-SERIF DIGIT ZERO
"〇"  IDEOGRAPHIC NUMBER ZERO
"〡〢〣〤〥〦〧〨〩〸〹〺"  HANGZHOU NUMERAL ONE~TEN, TWENTY, THIRTY
"㆒㆓㆔㆕"  IDEOGRAPHIC ANNOTATION ONE~FOUR MARK
"㈠㈡㈢㈣㈤㈥㈦㈧㈨㈩"  PARENTHESIZED IDEOGRAPH ONE~TEN
"㊀㊁㊂㊃㊄㊅㊆㊇㊈㊉"  CIRCLED IDEOGRAPH ONE~TEN
"一二三四五六七八九十壹貳參肆伍陸柒捌玖拾零百千萬億兆弐貮贰㒃㭍漆什㐅陌阡佰仟万亿幺兩㠪亖卄卅卌廾廿"  CJK UNIFIED IDEOGRAPH
"參拾兩零六陸什"  CJK COMPATIBILITY IDEOGRAPH
"𐄇𐄈𐄉𐄊𐄋𐄌𐄍𐄎𐄏𐄐𐄑𐄒𐄓𐄔𐄕𐄖𐄗𐄘"  AEGEAN NUMBER ONE~NINE, TEN~NINETY
"𐄙𐄚𐄛𐄜𐄝𐄞𐄟𐄠𐄡𐄢𐄣𐄤𐄥𐄦𐄧𐄨𐄩𐄪"  AEGEAN NUMBER ONE~NINE HUNDRED, ONE~NINE THOUSAND
"𐄬𐄭𐄮𐄯𐄰𐄱𐄲𐄳"  AEGEAN NUMBER TEN~NINETY THOUSAND
"𐅀𐅁𐅂𐅃𐅆𐅇𐅈𐅉𐅊𐅋𐅌𐅍𐅎𐅏𐅐𐅑𐅒𐅓𐅔𐅕𐅖𐅗𐅘𐅙𐅚𐅛𐅜𐅝𐅞𐅟𐅠𐅡𐅢𐅣𐅤𐅥𐅦𐅧𐅨𐅩𐅪𐅫𐅬𐅭𐅮𐅯𐅰𐅱𐅲𐅳𐅴"  GREEK ACROPHONIC ATTIC
"𝍠𝍡𝍢𝍣𝍤𝍥𝍦𝍧𝍨"  COUNTING ROD UNIT DIGIT ONE~NINE
"𝍩𝍪𝍫𝍬𝍭𝍮𝍯𝍰𝍱"  COUNTING ROD TENS DIGIT ONE~NINE
2 of 5
124

It's mostly about unicode classifications. Here's some examples to show discrepancies:

>>> def spam(s):
...     for attr in 'isnumeric', 'isdecimal', 'isdigit':
...         print(attr, getattr(s, attr)())
...         
>>> spam('½')
isnumeric True
isdecimal False
isdigit False
>>> spam('³')
isnumeric True
isdecimal False
isdigit True

Specific behaviour is in the official docs here.

Script to find all of them:

import sys
import unicodedata
from collections import defaultdict

d = defaultdict(list)
for i in range(sys.maxunicode + 1):
    s = chr(i)
    t = s.isnumeric(), s.isdecimal(), s.isdigit()
    if len(set(t)) == 2:
        try:
            name = unicodedata.name(s)
        except ValueError:
            name = f'codepoint{i}'
        print(s, name)
        d[t].append(s)
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.isdigit.html
pandas.Series.str.isdigit — pandas 3.0.6 documentation
For example, Python considers the ³ superscript character as a digit, but not the ⅕ fraction character, while PyArrow considers both as digits. For simple (ascii) decimal numbers, the behaviour is consistent. ... >>> s3 = pd.Series(["23", "³", "⅕", ""]) >>> s3.str.isdigit() 0 True 1 True 2 True 3 False dtype: bool
🌐
Programiz
programiz.com › python-programming › methods › string › isdigit
Python String isdigit()
Online Python Online JavaScript Online SQL Online Java Online HTML Online C Online C++ Online C# Online PHP Online Swift Online Kotlin Online TypeScript Online Go Online Rust Online Scala Online Dart Online R Online Ruby ... The isdigit() method returns True if all characters in a string are digits.
🌐
Qpython
qpython.com › python-isdigit-vs-isnumeric-2jcj
Python isdigit vs isnumeric – QPython+
January 7, 2026 - Use isdigit() for a strict check of decimal digits, and isnumeric() when you need to catch a wider range of Unicode numerals—fractions, superscripts, or other numeric symbols. Always test edge cases against your data set, and consider performance if you loop over millions of strings.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › str › isdigit.html
isdigit — Python Reference (The Right Way) 0.1 documentation
isdigit · Edit on GitHub · Returns a Boolean stating whether the string contains only digits. str. isdigit() bool · #TODO · For 8-bit strings, this method is locale-dependent. Returns False if string is empty.