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 196 views
1 answer 247 views
1 answer 204 views
1 answer 192 views
1 answer 222 views
1 answer 185 views
2 answers 219 views
...