python2 basic exercise

1. Convert list to dictionary

#!/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}

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325528579&siteId=291194637