The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #96
l = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]
[item for sublist in l for item in sublist]
[item for sublist in l for item in sublist] is a list comprehension. It iterates over every element in the sublists of l and creates a new flat list with them. (stackoverflow.com/questions/952914/how-to-make-a-flat-lis...)
What is the output of the following code snippet?
— The Python Quiz (@thepythonquiz) January 7, 2021
l = [[1, 2, 3], [4, 5, 6], [7], [8, 9]]
[item for sublist in l for item in sublist]
[[1, 2, 3], [4, 5, 6], [7], [8, 9]]
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[[1, 2, 3, 4, 5, 6, 7, 8, 9]]
π Comment the answer, like and retweet!
Question difficulty: π΅π΅π΅π΅π΅
Similar questions: