Latest web development tutorials

Python isdigit () method

Python strings Python strings


description

Are Python isdigit () method to detect a string consisting of only numbers.

grammar

isdigit () method syntax:

str.isdigit()

parameter

  • no.

return value

If the string contains only numeric Returns True otherwise False.

Examples

The following example shows an example of isdigit () method:

#!/usr/bin/python

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

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

Examples of the above output results are as follows:

True
False

Python strings Python strings