Issue
a = str(mergeSort(lines))
nlines = ['Sorted Numbers',a]
with open('SortedNumbers.txt', 'w') as f:
f.writelines(nlines)enter code here
mergeSort(lines) is my array of a few numbers. With this code above, the text file it creates does everything I want except all of it is on one line. How do I get it so the text file it produces will be
Sorted Numbers
1
3
5
8
10
Solution
a = "\n".join(mergeSort(lines));
Should put a newline after each of the numbers of your array.
It should print properly afterwards
Answered By - 0xRyN
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.