On Fri, 23 Jul 2010 09:51:37 am ANKUR AGGARWAL wrote: > hey i have just started making a app using python and just gt a > problem.. > > i have two list > a=["x","z"] > b=[1,2] > > i want to make a directory like this > c={"x":1,"z":2}
The word you want is "dictionary" or "dict", not directory. Here's one slow, boring, manual way: a = ["x", "z"] b = [1, 2] c = {} c[a[0]] = b[0] c[a[1]] = b[1] You can turn that into a loop: c = {} for index in range( min(len(a), len(b)) ): c[a[i]] = b[i] Here's the sensible way that makes Python do all the heavy lifting: c = dict(zip(a, b)) -- Steven D'Aprano _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor