21 lines
460 B
Python
21 lines
460 B
Python
def mysplit(string):
|
|
words = []
|
|
word = ""
|
|
for char in string:
|
|
if char != " ":
|
|
word += char
|
|
else:
|
|
if word:
|
|
words.append(word)
|
|
word = ""
|
|
if word:
|
|
words.append(word)
|
|
return words
|
|
|
|
|
|
print(mysplit("To be or not to be, that is the question"))
|
|
print(mysplit("To be or not to be,that is the question"))
|
|
print(mysplit(" "))
|
|
print(mysplit(" abc "))
|
|
print(mysplit(""))
|