I am trying to create a python script and need a little help
I am trying to create a python script and need a little help.
Im trying to write a program that will take 3 inputs and store in a text file. Input one will be a song title, two will be its highest place on the charts and three will be band memebrs and their instruments.
The output Im trying to get is <song name, hights place on charts, [member,instrument], [member2,instrumnet]..........> I want to do this for as many songs as I want to enter, and then be able to print all that data from the txt file.
Solution
#you might get intendation error in your system. correct it according to your ide.
entering=true
while(entering):
name = input(\"Song Name?\")
chart = input(\"hights place on charts\")
addmember=true
mem = [] #member list, to add required number of member.
while(addmember):
member=input(\"enter member\");
instrument=input(\"enter instrument\");
mein=member+instrument;
mem.append(mein) #appending members in list.
moremembers=input(\"press 1 to stop adding members\")
if moremembers==1:
addmember=false
fd = open(\"songsfile.txt\",\"w\")
fd.write(name)
fd.write(\' \')
fd.write(chart)
fd.write(\' \')
fd.write(\' \'.join(mem))
fd.close()
moresongs=input(\"press 1 to stop adding songs\")
if moresongs==1:
addmember=false
f = open(\"songsfile.txt\",\"r\")
contents = f.read()
f.close()
print contents
