writing a list to a txt file in python
python, python-3.x
Solution
myList = [1,2,3,4]
with open('path/to/output', 'w') as outfile:
outfile.write('\n'.join(str(i) for i in myList))
By the way, the list that you have in your post contains `int`s, not strings. Also, please NEVER name your variables `list` or `dict` or any other type for that matter
Problem
list consists of RANDOM strings inside it ``` #example list = [1,2,3,4] filename = ('output.txt') outfile = open(filename, 'w') outfile.writelines(list) outfile.close() ``` my result in the file ``` 1234 ``` so now how do I make the program produce the result that I want which is: ``` 1 2 3 4 ```