Writing


#1

Having problem with \n.

for a in my_list:
    my_file.write(str(a))

my_file.close()

is it just \n "\n" or ("\n"). and having problem where i would put it in code.

https://www.codecademy.com/courses/python-intermediate-en-OGNHh/0/3?curriculum_id=4f89dab3d788890003000096#


#2

Hi @mrschris ,

There are several ways that you can place a "\n" character at the end of a line of output. One possibility is the following, using string interpolation ...

    my_file.write("%d%s" % (a, "\n"))

#3

i used concatenation thanks


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.