Python String isascii() Method

The isascii() method is a string method that returns True if all the characters in the string are ASCII characters (a-z).

ASCII stands for American Standard Code for Information Interchange. It is a character encoding standard that uses numbers from 0 to 127 to represent English characters and some symbols.

For example:


name = "Alice"
print(name.isascii())

# prints True

The method returns False if the string contains any non-ASCII characters, such as accented letters, emojis, etc.

For example:


name = "Alïce"
print(name.isascii())

# prints False

If you have any questions about this code, you can drop a line in comment.

 

Comments