Created
March 19, 2014 20:34
-
-
Save pimiento/9650597 to your computer and use it in GitHub Desktop.
Есть два списка разной длины. В первом содержатся ключи, а во втором значения. Напишите функцию, которая создаёт из этих ключей и значений словарь. Если ключу не хватило значения, в словаре должно быть значение None. Значения, которым не хватило ключей, нужно игнорировать.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def dc(a, b): | |
res = {} | |
blen = len(b) | |
for i,e in enumerate(a): | |
res[e] = i < blen and b[i] or None | |
return res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment