0

py 2.7 I want to append a new line to my string when I call a.write() the problem is that the contenent is a variable. so, when i write

a.write(x,"/n") 

it gives me error cause i can't put more than 1 argument in (). any suggest?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
HANZO
  • 55
  • 1
  • 1
  • 8

1 Answers1

3

There are many ways of doing it

  • a.write(x+"\n")
  • a.write('{}\n'.format(x)
  • a.write('%s\n'%(x))

Note - \n is newline and not /n

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140