Hey all,
What wrong with the following syntax?
def save_file(sitelist,filename):
out_file = open(filename,"w")
for site in sitelist.keys():
out_file.write(site+","+sitelist[site][0]+","+sitelist[site][1]"\n")
sitelist[site][1]"\n" is not valid. I think you want sitelist[site][1] + "\n"
out_file.close()
You can simplify things by using items():
for key, value in sitelist.items():
out_file.write(key +","+value[0] +","+value[1]+"\n")
% formatting can make it even nicer:
out_file.write("%s,%s,%s\n" % (key, value[0], value[1])
It highlighted the last " if that will help any.
I can't show you the error due to the fact that the error appeared in a separate box, instead of in the IDLE window.
If you need the rest of the code, just ask. It ran perfect before I added file I/O.
Thanks in advance,
Nathan Pinno
Crew, Camrose McDonalds and owner/operator of Woffee
Just out of curiosity, would you explain "Crew, Camrose McDonalds and owner/operator of Woffee"
phone 510 978 4454
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor