28.10.2021 Views

Python Tutorial ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Parameters

• NA

Return Value

This method returns true if all characters in the string are alphabetic and there is at least one character, false

otherwise.

Example

The following example shows the usage of isalpha() method.

#!/usr/bin/python

str = "this"; # No space & digit in this string

print str.isalpha();

str = "this is string example....wow!!!";

print str.isalpha();

Let us compile and run the above program, this will produce the following result:

True

False

isdigit()

Description

The method isdigit() checks whether the string consists of digits only.

Syntax

Following is the syntax for isdigit() method:

str.isdigit()

Parameters

• NA

Return Value

This method returns true if all characters in the string are digits and there is at least one character, false

otherwise.

Example

The following example shows the usage 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();

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!