2
I have a problem with my code. I have 3 functions, one of them uses an input method called tweet but when I call the error function and does not perform, maybe I did not understand this part of input methods but I reviewed a few times and to me seems to be right.
I read a file with this function:
def le_tweets():
lista = []
file = codecs.open("tweets_prova.txt", encoding='utf-8')
for l in file:
lista.append(l.replace('\n',''))
return lista
I take the value of the previous function and return it to a variable later
def carregaTweets():
lista = ''
lista = le_tweets()
return lista
And this function to separate the text by words
def separa_palavras(tweet):
return tweet.split(' ')
I can receive the text from the file I read, but when I use the error separa_words(tweet) and I don’t know what to change to resolve.
tweet = carregaTweets()
lista = separa_palavras(tweet)
print(lista)
What’s the mistake? Be more specific
– mercador
Traceback (Most recent call last): File "C: Users Jhonatan.Teodoro Desktop work activity_raaluno1_raaluno2.py", line 58, in <module> list = (separa_words(tweet)) File "C: Users Jhonatan.Teodoro Desktop work activity_raaluno1_raaluno2.py.", line 23, in separa_palavras Return tweet.split(' ') Attributeerror: 'list' Object has no attribute 'split'
– Jhonatan Teodoro