.isprintable()
Anonymous contributor
Published Sep 22, 2023
Contribute to Docs
.isprintable()
is a string method that returns a boolean value True
if all characters in the string are printable or if it’s empty, and False
if any character in the string is non-printable.
Syntax
mystr.isprintable()
This method is called on a string mystr
and returns True
if all characters in mystr
are printable.
Example
In the following example, .isprintable()
is used to find out if all characters in the strings are printable.
str = "Hello World"str1 = "Hello World\n"str2 = "@Hello $World"str3 = "\tHello World"print(str.isprintable())print(str1.isprintable())print(str2.isprintable())print(str3.isprintable())
The output of the above code will be:
TrueFalseTrueFalse
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Python on Codecademy
- Skill path
Analyze Data with Python
Learn to analyze and visualize data using Python and statistics.Includes 8 CoursesWith CertificateIntermediate13 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours