You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I tried the code in Chapter2 Listing 2.3, which is the following:
text = 'Define which data represents "ham" class and which data represents "spam" class for the machine-learning algorithm.'
text = "i. e."
delimiters = ['"', "."]
words = []
current_word = ""
for char in text:
if char==" ":
if not current_word=="":
words.append(current_word)
current_word = ""
elif char in delimiters:
if current_word=="":
words.append(char)
else:
words.append(current_word)
words.append(char)
current_word = ""
else:
current_word += char
print(words)
But it returned [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']. Would you happen to know why?
The text was updated successfully, but these errors were encountered:
Hi. I tried the code in Chapter2 Listing 2.3, which is the following:
text = 'Define which data represents "ham" class and which data represents "spam" class for the machine-learning algorithm.'
text = "i. e."
delimiters = ['"', "."]
words = []
current_word = ""
for char in text:
if char==" ":
if not current_word=="":
words.append(current_word)
current_word = ""
elif char in delimiters:
if current_word=="":
words.append(char)
else:
words.append(current_word)
words.append(char)
current_word = ""
else:
current_word += char
print(words)
But it returned [' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']. Would you happen to know why?
The text was updated successfully, but these errors were encountered: