Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created June 29, 2020 02:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/c6fcb086f2033bb98ad93863fb75d9db to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/c6fcb086f2033bb98ad93863fb75d9db to your computer and use it in GitHub Desktop.
#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