Skip to content Skip to sidebar Skip to footer

Typeerror: Must Be Str, Not List

the problem is output result is not save in csv file. I'm using this code to weight-age the words positive and negative.I want to save in the csv file.Firstly, read the csv file ,a

Solution 1:

Try to this.

sorted_words = ''.join(sorted(scores.items(), reverse=True))

Solution 2:

As you dont specify in your post, I dont know which is the separator between values of the tuple, so I added a '\n'. You can change that to ' ' or whatever you want.

final = open("tfidf.csv", "w").write('\n'.join('%s, %s' % x for x in sorted_words))

Post a Comment for "Typeerror: Must Be Str, Not List"