Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python Exercise Example 100

Python Exercise Example 100

Python 100 Examples Python 100 Examples

**Question:** Convert a list to a dictionary.

**Analysis:** None.

Program source code:

Example

#!/usr/bin/python

-- coding: UTF-8 --

i

=

[

'

a

'

,

'

b

'

]

l

=

[

1

,

2

]

print

dict

(

[

i

,

l

]

)

The output of the above example is:


{'a': 'b', 1: 2}

Python 100 Examples Python 100 Examples