Answers for "how to write in a new line in python"

3

python writelines newline

lines = ['line1', 'line2']
with open('filename.txt', 'w') as f:
    f.writelines("%sn" % l for l in lines)
Posted by: Guest on October-19-2020
1

python write text file on the next line

file = open("sample.txt", "w")
file.write("Hellon")
file.write("Worldn")
file.close()
Posted by: Guest on November-08-2020
0

new line in python

''' simple'''
print()
''' long way'''
print('n',end='')
Posted by: Guest on September-30-2020
1

new line print python

print("Hello Worldn" "This is the second line")
Posted by: Guest on October-09-2020

Code answers related to "how to write in a new line in python"

Python Answers by Framework

Browse Popular Code Answers by Language