On 7/22/2010 7:51 PM, 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

Do you mean "dictionary"?

c={"x":1,"z":2}

is it possible????

Indeed. There are several ways to do this. Easiest:

dict(zip(a,b))

i mean i tried it using loops

d = {}
for i in range(len(a)):
  d[a[i] = b[i]

and all but i cant append a directory

Of course you can't append, since a dictionary is not a sequence. But you can add a key-value pair as the above loop demonstrates.

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to