def writetofile():
myFile = open("C:\Jazmyn\myText.txt", "a")
myFile.write(a)
myFile.close()
# creating new text file, I have created a folder named "Jazmyn"
# in my C drive and the text file is created there.
def greenbottles():
bottle = ['Zero','One','Two','Three','Four','Five','Six','Seven','Eight', 'Nine', 'Ten' ]
text_one = 'green bottles hanging on the wall'
text_two = 'And if one green bottle should accidentally fall\nThere\'ll be'
for i in range(10, 0, -1):
print(bottle[i], text_one)
print(bottle[i], text_one)
print(text_two, bottle[i-1], text_one)
greenbottles()
# this needs to be written to the file
私はpythonが初めてで、難しいと感じています。greenbottles
コードを新しいテキスト ファイル (myText) に書き込めるようにすることは可能ですか、それともファイルに書き込めるようにステートメントを修正できますprint
か?