next line thingy doesn't work when used proper syntax

23 Views Asked by At
f.write(str(Path))
f.write("\n")
f.write(str(Monthly))

path is a string but Monthly is date. I can Insert all in a text file but I am not getting the desired output:

The output that I wish should be

D:\python
2021-04-08

But the output that I get is

D:\python
               <---causing error is this gap 
2021-04-08

The extra line after the path is causing problems.

1

There are 1 best solutions below

1
On

You literally used two newlines that caused the blank space. You may remove any of them to fix the issue for getting the desired output.

f.write(str(Path))
f.write("\n")
f.write(str(Monthly))