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 the last item in dict to the file which is "heba6677..." . Thanks for your help.
ab={'engy':'011199887765', 'wafa2':'87878857578', 'heba':'6677553636'} for name, mobile in ab.items(): print ('Contact %s at %s' % (name, mobile)) f=open('D:\glo.txt','w') f.write(name) f.write(mobile) f.close()