fork download
  1. def f(k,v):
  2. dict={}#Создаем словарь
  3. klen=len(k)# Колво ключей
  4. vlen=len(v)# Колво значений
  5. for i in range(min(klen,vlen)):
  6. dict[k[i]]=v[i]#
  7. if klen>vlen:#
  8. for i in range(vlen,klen):#
  9. dict[k[i]]=None#
  10. return dict
  11. k=[1,2,3,4,5]
  12. v=[1,2,3]
  13. print(f(k,v))
  14. k=[1,2]
  15. v=[1,2,3]
  16. print(f(k,v))
  17. k=[1,2,3]
  18. v=[1,2,3]
  19. print(f(k,v))
Success #stdin #stdout 0.03s 9984KB
stdin
Standard input is empty
stdout
{1: 1, 2: 2, 3: 3, 4: None, 5: None}
{1: 1, 2: 2}
{1: 1, 2: 2, 3: 3}