Python String isprintable() Method

Python isprintable() method returns True if all characters in the string are printable or the string is empty. It returns False if any character in the string is Nonprintable.

Signature

Parameters

No parameter is required.

Return

It returns either True or False.

Let's see some examples of isprintable() method to understand it's functionalities.

Python String isprintable() Method Example 1

It is a simple example that prints True, if the string is printable. See the example below.

Output:

True

Python String isprintable() Method Example 2

Here, we are using some other characters like newline and tabs in the string. See the results of the example.

Output:

True
False
False

Python String isprintable() Method Example 3

Testing different-different string values which contains special chars too. In case of special chars, method returns False.

Output:

It is printable
It is printable
Not printable

Next TopicPython Strings




Latest Courses