I am trying to write a code to print the song ten green bottles into a text file that finds and opens a notepad file under the name "ten green bottles". Although I am having major issues with the opening and printing into a text file part need help to make this happen. I will be very appreciative if you could aid in resolving this problem:
StringList = ['Ten ','Nine ','Eight ','Seven ','Six ','Five ','Four ','Three ','Two ','One ']
StringList2 = ['ten','nine ','eight ','seven ','six ','five ','four ','three ','two ', 'one ','no ']
string1 = ("green bottle \nHanging on the wall\n")
string2 = ("green bottle\nHanging on the wall\nAnd if one green bottle")
string3 = ("\nShould accidently fall\nThere'll be ")
string4 = ("green bottles \nHanging on the wall \n")
string5 = ("green bottles\nHanging on the wall\nAnd if one green bottle")
string6 = ("green bottle\nHanging on the wall\n")
def loopingverse():
verse1 =''
for x in range (0 , 10):
if x > 8: verse1 = verse1 + (StringList[x] + string1 + StringList[x] + string2+string3 + StringList2[x + 1] + string4 + "\n")
if x == 8: verse1 = verse1 + (StringList[x] + string4 + StringList[x] + string5 + string3 + StringList2[x + 1] + string6 + "\n")
if x < 8: verse1 = verse1 + (StringList[x] + string4 + StringList[x] + string5+string3 + StringList2[x + 1] + string4 + "\n")
return verse1
import subprocess
subprocess.call(['notepad.exe', 'ten green bottles.txt'])
if __name__ == '__loopingverse__':
loopingverse()