Python tip 8: dict.fromkeys() method

Pubblicato il: 30 marzo 2022
sul canale di: 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...


In questa pagina del sito puoi guardare il video online Python tip 8: dict.fromkeys() method della durata di ore minuti seconda in buona qualità , che l'utente ha caricato learnbyexample 30 marzo 2022, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 828 volte e gli è piaciuto 17 spettatori. Buona visione!