Tutorial Gateway

  • C
  • C#
  • Python
  • SQL
  • Java
  • JS
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs
  • MySQL

Python isdigit

The Python isdigit string function is used to check whether the character is a digit or not. In this section, we discuss how to write or use this string isdigit Function in Python Programming with example.

Python isdigit Syntax

The syntax of is digit in Python function is

String_Value.isdigit()

The isdigit string function returns a Boolean value as an output.

  • If the String_Value is a valid digit, then it returns TRUE
  • If the String_Value is not a valid digit, then the string isdigit function returns FALSE

Program to Check for Digit using Python isdigit function

The following set of examples helps you understand the string isdigit function and how to use it.

# Python isdigit Method Example

Str1 = '123456789';
print('First Output of a isdigit() method is = ', Str1.isdigit())

Str2 = '     ';
print('Output of a isdigit() method For Empty Space is = ', Str2.isdigit())

# Performing isdigit() function directly
Str3 = 'Find Tutorial at Tutorial Gateway'.isdigit()
print('Second Output of a isdigit() method is = ', Str3)

# Performing isdigit() on both Digits and Alphabets
Str5 = '123456789a'.isdigit()
print('Third Output of a isdigit() method is = ', Str5)

# Performing isdigit() on Float values
Str6 = '1234.67'.isdigit()
print('Fourth Output of a isdigit() method is = ', Str6)

# Performing isdigit() on Negative Values  
Str7 = '-1234'.isdigit()
print('Fifth Output of a isdigit() method is = ', Str7)
Python IsDigit Function 1

First, we declared the String variable Str1 and assigned corresponding value (Integer Value) using the following statement. Next, we used the isdigit function to check whether the string is a digit or not. As you can see from the below code, it is a valid digit. So, the isdigit String function returns TRUE.

Str1 = '123456789';
print('First Output of a isdigit() method is = ', Str1.isdigit())

The following Python statement checks whether the Empty space is a valid digit or not.

Str2 = '     ';
print('Output of a isdigit() method For Empty Space is = ', Str2.isdigit())

Next, we are using the string isdigit function in python on the following group of words

Str3 = 'Find Tutorial at Tutorial Gateway'.isdigit()
print('Second Output of a isdigit() method is = ', Str3)

Filed Under: Python

  • Download and Install Python
  • Python Arithmetic Operators
  • Python Assignment Operators
  • Python Bitwise Operators
  • Python Comparison Operators
  • Python Logical Operators
  • Python If Statement
  • Python If Else
  • Python Elif Statement
  • Python Nested If
  • Python For Loop
  • Python While Loop
  • Python Break
  • Python Continue
  • Python Dictionary
  • Python datetime
  • Python String
  • Python Set
  • Python Tuple
  • Python List
  • Python List Comprehensions
  • Python Lambda Function
  • Python Functions
  • Python Types of Functions
  • Python Iterator
  • Python File Handling
  • Python Directory
  • Python Class
  • Python classmethod
  • Python Inheritance
  • Python Method Overriding
  • Python Static Method
  • Connect Python and SQL Server
  • Python SQL Create DB
  • Python SQL Select Top
  • Python SQL Where Clause
  • Python SQL Order By
  • Python SQL Select Statement
  • Python len Function
  • Python max Function
  • Python map Function
  • Python print Function
  • Python sort Function
  • Python range Function
  • Python zip Function
  • Python Math Functions
  • Python String Functions
  • Python List Functions
  • Python NumPy Array
  • NumPy Aggregate Functions
  • NumPy Arithmetic Operations
  • Python Numpy Bitwise operators
  • Numpy Comparison Operators
  • Numpy Exponential Functions
  • Python Numpy logical operators
  • Python numpy String Functions
  • NumPy Trigonometric Functions
  • Python random Array
  • Python numpy concatenate
  • Python numpy Array shape
  • Python pandas DataFrame
  • Pandas DataFrame plot
  • Python Series
  • Python matplotlib Histogram
  • Python matplotlib Scatter Plot
  • Python matplotlib Pie Chart
  • Python matplotlib Bar Chart
  • Python List Length
  • Python sort List Function
  • Python String Concatenation
  • Python String Length
  • Python substring
  • Python Programming Examples

Copyright © 2021ยท All Rights Reserved by Suresh.
About | Contact | Privacy Policy