-
-
Save IndhumathyChelliah/c6fcb086f2033bb98ad93863fb75d9db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#string containing space | |
s1="example of strings" | |
print (ascii(s1)) #Output:'example of strings' | |
print (s1.isascii()) #Output:True | |
#empty string | |
s2='' | |
print (ascii(s2))#Output:'' | |
print (s2.isascii())#Output:True | |
#string containing alphabets | |
s3="apple" | |
print (ascii(s3))#Output:'apple' | |
print (s3.isascii())#Output:True | |
#string containing special characters | |
s4="#$%" | |
print (ascii(s4))#Output:'#$%' | |
print (s4.isascii())#Output:True | |
#string containing numbers and alphabets | |
s5="123abc" | |
print (ascii(s5))#Output:'123abc' | |
print (s5.isascii())#Output:True | |
#° - doesn't have printable reprsentation. So returns False. | |
s6="degree °" | |
print (ascii(s6))#Output:'degree \xb0' | |
print (s6.isascii())#Output:False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment