Error using input method in function with Python

1

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 function of the error and it does not execute, maybe I did not understand this part of input methods right but I reviewed it a few times and for me it 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 get the value of the previous function and return to by a variable after

def carregaTweets():
        lista = ''
        lista = le_tweets()
        return lista

And this function to separate text by words

def separa_palavras(tweet):
    return tweet.split(' ')

I can receive the text from the file I read, however when I use the separates_words (tweet) from the error and I do not know what to change to solve.

tweet = carregaTweets()
lista = separa_palavras(tweet)
print(lista)
    
asked by anonymous 11.06.2017 / 19:51

1 answer

0

Your carregaTweets() method returns a list of strings. Therefore, separa_palavras(tweet) receives a list of strings per parameter. You are trying to call split in the whole list, and you can not give split to a list, only in a string.

    
11.06.2017 / 20:42