Join Regular Classroom : Visit ClassroomTech

Python String – isdigit() method

It is a method in python that checks if the given string has all the characters as digit in it.
If the string satisfies the condition it returns True else returns False.

Syntax:

string.isdigit()

Example 1:

s = “123
x = s.isdigit()
print(x)

Output:

True

Explanation:

Here the given string has all the characters as digits. Hence returned True.

Example 2:

s = “code123
x = s.isdigit()
print(x)

Output:

False

Explanation:

Here the string has alphabets in it along with the digits. Hence returned False.

You Missed
Also Checkout