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 291 views
1 answer 347 views
1 answer 295 views
1 answer 289 views
1 answer 303 views
1 answer 273 views
2 answers 321 views
...