-4

How can i make a textfile from the input off the user?

f = open('test.txt','w')

    date = input("which day is it")

print("" + date)

2 Answers2

0

Use the write() function.

date = input("which day is it")

with open('test.txt','w') as f:
    f.write(date)
Tom Gebel
  • 744
  • 1
  • 4
  • 13
0
with open("text.txt","a") as txt_file:
    txt_file.write(input("What is your name?\n"))
Boris Kayi
  • 486
  • 7
  • 13