Update to_dictionary

Fixes #203
This commit is contained in:
Isabelle Viktoria Maciohsek
2020-10-03 17:24:50 +03:00
parent c786846177
commit ece05ed413

View File

@ -6,11 +6,11 @@ tags: list,dictionary,intermediate
Combines two lists into a dictionary, where the elements of the first one serve as the keys and the elements of the second one serve as the values.
The values of the first list need to be unique and hashable.
- Use `zip()` in combination with a list comprehension to combine the values of the two lists, based on their positions.
- Use `zip()` in combination with the `dict()` constructor to combine the values of the two lists into a dictionary.
```py
def to_dictionary(keys, values):
return {key:value for key, value in zip(keys, values)}
return dict(zip(keys, values))
```
```py