Python tip 8: dict.fromkeys() method

Published: 30 March 2022
on channel: learnbyexample
828
17

A lesser known way to create a dictionary is to use the `fromkeys()` method that accepts an iterable and an optional value (default is `None`).

Recent Python versions ensure that the insertion order is maintained for a dictionary. So, you can remove duplicate items from a list while maintaining the order by building a dictionary using the `fromkeys()` method and converting it back to a list.

This video is based on content from my "100 Page Python Intro" ebook: https://github.com/learnbyexample/100...


On this page of the site you can watch the video online Python tip 8: dict.fromkeys() method with a duration of hours minute second in good quality, which was uploaded by the user learnbyexample 30 March 2022, share the link with friends and acquaintances, this video has already been watched 828 times on youtube and it was liked by 17 viewers. Enjoy your viewing!