Home >>Python String Methods >Python String isprintable() Method

Python String isprintable() Method

Python String isprintable() Method

Python String isprintable() Method is an built-in method returns true if all the characters are printable in the string, otherwise, it returns False.

Syntax:
string.isprintable()
Here is an Example of Python String isprintable() Method:

printable = "Hello! phptpoint #12?"
x = printable.isprintable()
print(x)

Output:
True
Example 2:

str = "Hello, phptpoint"  
if str.isprintable() == True:  
    print("It is printable")  
else:  
    print("Not printable")  
str = "$Hello@phptpoint#"    
if str.isprintable() == True:  
    print("It is printable")  
else:  
    print("Not printable")  
str = "Hello\nphptpoint"  
if str.isprintable() == True:  
    print("It is printable")  
else:  
    print("Not printable")  

Output:
It is printable
It is printable
Not printable

No Sidebar ads