The Python Oracle

How to initialize a dict with keys from a list and empty value in Python?

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC F Haydns String Quartet No 53 in D

--

Chapters
00:00 Question
00:35 Accepted answer (Score 519)
01:25 Answer 2 (Score 350)
01:52 Answer 3 (Score 78)
02:01 Answer 4 (Score 22)
02:29 Thank you

--

Full question
https://stackoverflow.com/questions/2241...

Accepted answer links:
[dict.fromkeys]: https://docs.python.org/3/library/stdtyp...
[How can I initialize a dictionary whose values are distinct empty lists?]: https://stackoverflow.com/questions/1150...

Answer 2 links:
[dict comprehension]: https://stackoverflow.com/questions/1747...

Answer 4 links:
[list comprehension]: https://stackoverflow.com/questions/3483...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#dictionary #python

#avk47