i have 5 variables and i want to write them all to a text file using 1 line of code rather than repeating the x.write() function 5 times. Im really not sure how to do this please help
2 Answers
If you're using Python 3.6 or newer, you can use PEP-498 F-strings, to do it concisely
with open("path/to/file", "w") as f:
f.write(f"{var1}{var2}{var3}{var4}{var5}")