Search Results

Search found 1 results on 1 pages for 'gfar90'.

Page 1/1 | 1 

  • python writing a list to a file

    - by gfar90
    I need to write a list to a file in python. I know the list should be converted to a string with the join method, but since I have a tuple I got confused. I tried a lot to change my variables to strings etc, this is one of my first attempts: def perform(text): repository = [("","")] fdist = nltk.FreqDist(some_variable) for c in some_variable: repository.append((c, fdist[c])) return ' '.join(repository) but it gives me the following error: Traceback (most recent call last): File "", line 1, in qe = perform(entfile2) File "", line 14, in perform return ' '.join(repository) TypeError: sequence item 0: expected string, tuple found any ideas how to write the list 'repository' to a file? Thanks!

    Read the article

1