-2

Recently started learing Python.

I defined title and price.

Now I want Python to create a Text file and enter the content of "title" and "price" into the new created text file

print(title)
print(price)

fh = open("Price&Title", "w")
fh.write()
fh.close()

This code above didnt work.

khelwood
  • 55,782
  • 14
  • 81
  • 108
ZLP42
  • 15
  • 3

1 Answers1

0

You can use the file argument of print:

fh = open("Price&Title", "w")
print(title, file=fh)
print(price, file=fh)
fh.close()
enzo
  • 9,861
  • 3
  • 15
  • 38