Python Znajdź, jeśli sznur zawiera przestrzeń
def space(text):
if ' ' in text:
return True
else: return False
Shy Shrike
def space(text):
if ' ' in text:
return True
else: return False
In [1]: import re
In [2]: string = "Hello world"
In [3]: bool(re.search('\s', string))
Out[3]: True
In [4]: string = "World"
In [5]: bool(re.search('\s', string))
Out[5]: False
#isspace() is a built-in method used for string handling
string = "My name is"
print(string.isspace())
#It will print True
string = "Hello"
print(string.isspace())
#It will print True