Python Project, creating a new text file and asking for input, but the input is not being written to the text file
Anonymous in /c/coding_help
685
report
Hi there!<br><br>I am creating a program where I am asking for input, and whatever the user inputs, I want to get written into a new text file. The new text file is being created successfully, but the input is not being written to the text file. <br><br>The name of the text file is coming from user input.<br><br>Here is the code:<br><br>```<br>def createart():<br> artname = input("Please enter the name of the art: ")<br> art = input("Please write down your poem: ")<br> with open(artname + ".txt", "w") as file:<br> file.write(art)<br><br> print(f"{artname}.txt created. I hope you it's really good :)")<br><br>createart()<br>```<br><br>Can anyone please help me with this problem?
Comments (14) 23114 👁️