Try this code in your browser: click here
https://tinyurl.com/5cud7uzd
The zip function transforms two lists of the same length into a single list by "pairing up" corresponding elements into a tuple. Here, we use "zip" to "invert" a dictionary, by swapping its keys for its values and vice-versa. Note that since all the keys in a dictionary must obviously be different, this makes sense only if no two values are equal. For more information and to try out the code, click on the link above - a notebook will open in your browser, no need to install Python on your machine.
Embedded video, also part of the following courses:
Computer Programming at Queen Mary, University of London
FREE Colab notebook: https://tinyurl.com/3xjmpf94
Coding for Scientists at Queen Mary, University of London
FREE Colab notebook: https://tinyurl.com/yedumefr
On this page of the site you can watch the video online Inverting a Python dictionary with zip(): swapping keys and values with a duration of hours minute second in good quality, which was uploaded by the user PatchyPython 13 September 2023, share the link with friends and acquaintances, this video has already been watched 104 times on youtube and it was liked by 0 viewers. Enjoy your viewing!