+ 1

Why it won't pass me in? Pyton 48.2 Practise "New Line"

Task from Python Core 48.2 "New Line": You are given the following list: names = ["John", "Oscar", "Jacob"] Complete the program to create a file where you write the names from the list, each on a new line, and separately output them. correct output: John Oscar Jacob ========= My code: names = ["John", "Oscar", "Jacob"] file = open("names.txt", "w+") for name in names: file.write(name + " \n") file.close() file= open("names.txt", "r") print(file.read()) file.close() my output: John Oscar Jacob where did I make mistake?

12th Dec 2021, 10:42 AM
Alex Bulkowski
Alex Bulkowski - avatar
2 Respuestas
+ 4
Replace " \n" with "\n"
12th Dec 2021, 10:50 AM
Simon Sauter
Simon Sauter - avatar
0
that works!!! Thank you so much!
13th Dec 2021, 5:31 AM
Alex Bulkowski
Alex Bulkowski - avatar