What is list and dictionary comprehension and why are they used | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is list and dictionary comprehension and why are they used

8th Aug 2019, 5:42 PM
SUNDARAMAN IYER
SUNDARAMAN IYER - avatar
2 Answers
+ 1
I got it.👍
9th Aug 2019, 4:06 AM
SUNDARAMAN IYER
SUNDARAMAN IYER - avatar
0
They are used to simplify the creation of a container with content. Regular way: letters = [] for n in range(10): letters.append(chr(n)) Comprehensive way: letters = [chr(n) for n in range(10)]
8th Aug 2019, 6:35 PM
HonFu
HonFu - avatar