I\'m new with Python and I know that piece of code is very simple and lacks some statements, actually I need to write to file from dictionary. This code runs but only writes
If you want to keep adding lines to your file, open it with the a mode, as described in the documentation:
for (name, mobile) in ab.iteritems():
with open(...., "a") as f:
print ('Contact %s at %s' % (name, mobile))
f.write(name)
f.write(mobile)
Using w as mode means writing: your file will be overwritten.