I have working code here which takes two lists and turns them into a dictionary with the first list being the keys and the second being the values. If the keys exceed the values the value "None" will be assigned to that key.
def createDict(keys, values):
i = 0
dictionary = {}
# go through all the values in the first list
for key in keys:
# if our keys index is equal or exceeds our value list's length
# then extend the list with a None value
if i >= len(values):
values.extend([None])
dictionary[key] = values[i]
i = i + 1
return dictionary
I was hoping for to get some feedback.
dict(itertools.zip_longest(keys, values))
\$\endgroup\$keys
is shorter thanvalues
. \$\endgroup\$