Python 3 reference · String Methods

Python String isascii() Method

Return True if the string is empty or every character is ASCII (code points 0–127).

Python 3 Since 3.7

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

str.isascii()

Return value

True or False.

Examples

ASCII or notTry it yourself
print("hello".isascii(), "héllo".isascii(), "".isascii())

Output

True False True
Find non-ASCII wordsTry it yourself
words = ["cafe", "café", "naive", "naïve"]
print([w for w in words if not w.isascii()])

Output

['café', 'naïve']

Version history

VersionChange
Python 3.7Added

Was this page helpful?