0

code not writing to file

this code isn't writing to the file there's no errors and I've checked using alt+x and ran the file to test if it works but the file isn't getting updated https://code.sololearn.com/ctFYuLJ7nvN3/#py

28th Apr 2022, 9:25 AM
charlotte
7 odpowiedzi
0
This code is just writing newlines to the file. It should write i.
28th Apr 2022, 11:11 AM
m.ali.a
m.ali.a - avatar
0
Why is function write_to_file definition inside a "for" loop and an "if" statement? The code only writes newlines (\n) to the file. Is that what you intended? For you to add code, just write it in Code Playground, save as public, then edit your question with a link to it.
29th Apr 2022, 1:28 PM
Emerson Prado
Emerson Prado - avatar
0
ive added the link
5th May 2022, 7:59 AM
charlotte
0
m.ail.a if i use (i,'\n') i get the error "TypeError: write() takes exactly 1 argument (2 given)"
5th May 2022, 9:30 AM
charlotte
0
jackie That's what's expected. write does take just one argument. What do you intend to write?
5th May 2022, 9:45 AM
Emerson Prado
Emerson Prado - avatar
0
the out put of the second for loop
9th May 2022, 9:18 AM
charlotte
0
jackie Do you mean the list contents? Two hints: You want to concatenate 'i' and a newline. Use '+' to concatenate strings. Change your list variable name. 'list' is a data type. Overwriting is a Bad Thing.
21st May 2022, 12:51 AM
Emerson Prado
Emerson Prado - avatar