I need to create a text file and write to it, I am very new to programming all together and I would like some advice.
#part1
def writetofile():
myFile = open("C:\Andrew\myText.txt", "a")
myFile.write(a)
myFile.close()
#part2
def textfileopen():
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])
textfileopen()
#part3
I was given an example:
def kevin():
File = open('abc.txt','a')
File.write(a)
File.close()
def skinner ():
kevin('rabbits')
skinner()
My program is suppose to execute from the "skinner" or "textfileopen" (Am i missing a python main block?) Part 3 is suppose to execute the program and call part 2 and then part 2 calls part 1 to create the text file. I know you cannot start a program with a def, I am making mistakes with my defs I think but I can't work out what exactly i am stuffing up. I could use some advice or help thanks.