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
# i provided this solution earlier it had indentaion problem, not this solution is working perfectly fine.
#=======code=================
#you might get intendation error in your system.
 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=int(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=int(input(\"press 1 to stop adding songs\"))
 if moresongs==1:
 entering=False
f = open(\"songsfile.txt\",\"r\")
 contents = f.read()
 f.close()
print (contents)

