Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list1=[1,2,3,4]
- list2=["qwe","asd","zxc"]
- dictx={}
- for x in range(len(list1)):
- if x>len(list2):
- dictx[list1[x]]=None
- else:
- dictx[list1[x]]=list2[x]
- from itertools import chain, repeat
- d = dict(zip(list1, chain(list2, repeat(None))))
- import itertools
- list1=[1,2,3,4]
- list2=["qwe","asd","zxc"]
- print ({l1:l2 for l1,l2 in itertools.izip_longest(list1,list2,fillvalue=None)})
- import itertools
- list1=[1,2,3,4]
- list2=["qwe","asd","zxc"]
- print ({l1:l2 for l1,l2 in itertools.zip_longest(list1,list2,fillvalue=None)})
- {1: 'qwe', 2: 'asd', 3: 'zxc', 4: None}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement