How to determine if a character is whitespace in Python

1 Answer

0 votes
ch = 'a'
if ch.isspace():
    print("yes")
else:
    print("no")

ch = ' '
if ch.isspace():
    print("yes")
else:
    print("no")

ch = '\n'
if ch.isspace():
    print("yes")
else:
    print("no")

ch = '\t'
if ch.isspace():
    print("yes")
else:
    print("no")


'''
run:

no
yes
yes
yes

'''

 



answered Dec 7, 2016 by avibootz

Related questions

1 answer 198 views
1 answer 252 views
1 answer 212 views
1 answer 194 views
1 answer 225 views
1 answer 192 views
2 answers 221 views
...