list to dict
peter at engcorp.com
Wed Jun 16 18:15:24 CEST 2004
Bart Nessux wrote:
> Peter Hansen wrote:
>> A dictionary has key/value pairs. How do you want to map
>> the elements of your list to this format? In pairs, or
>> are you using them all as keys, or something else?
> 1 = book1
> 2 = book2
> 3 = book3
This is much less clear than you might have thought, although
with any luck Yermat and Larry have interpreted it correctly.
Can you represent the list as you would in Python? Then
we'll know exactly what you are talking about. Or did you
not even mean that you had a Python list, but merely a "list"
of things, maybe in a file?
The above could be interpreted at least these ways:
1. lines in a file
2. [1, book1, 2, book2, 3, book3]
3. [book1, book2, book3]
4. ['book1', 'book2', 'book3']
5. ['1 = book1', '2 = book2', '3 = book3']
and probably many others.
More information about the Python-list