"remi" <[EMAIL PROTECTED]> wrote:

> i = 0
> while i<=len(mylist)
>    variable['s_i']=mylist.pop()
>    i = i+1

    variable['s_' + str(i)]=mylist.pop()

but that while and pop stuff is pretty weird; maybe you should read the
sections on lists, for loops, and string formatting in the Python tutorial?

here's a shorter way to create that dictionary:

    variable = {}
    for item in mylist:
        variable["s_%d" % len(variable)] = item

and here's the obligatory one-liner:

    variable = dict(("s_" + str(k), v) for k, v in enumerate(mylist))

(shorter, but not exactly clearer, especially not if you're new to Python)

</F> 



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to