Copyright © tutorialspoint.com

Python String isdigit() Method

previous next


Description:

This method checks whether the string consists of digits only.

Syntax:

str.isdigit()

Parameters:

Here is the detail of parameters:

Return Value:

It return true if all characters in the string are digits and there is at least one character, false otherwise.

Example:

#!/usr/bin/python


str = "123456";  # Only digit in this string
print str.isdigit();

str = "this is string example....wow!!!";
print str.isdigit();

This will produce following result:

True
False

previous next

Copyright © tutorialspoint.com