#student example demonstrating file output in a comma-separated values format print "Enter students names, ids, and years" nameList = [] IDList = [] yearList = [] name = raw_input("Name: ") while name != "": nameList.append(name) ID = raw_input("ID: ") IDList.append(ID) year = raw_input("Year: ") yearList.append(int(year)) name = raw_input("Name: ") #print name,id,year for each student on one line of the file fileOut = file("studentInfo.txt","w") for index in range(len(nameList)): fileOut.write(nameList[index] + ",") fileOut.write(IDList[index] + ",") fileOut.write(str(yearList[index]) + "\n") fileOut.close()