MCQs>IT & Programming>Python>How would you write the following with a list comprehension? x = [] for i in range(5): x.append([]) for j in range(10): x[-1].append(j)
Python MCQs
How would you write the following with a list comprehension? x = [] for i in range(5): x.append([]) for j in range(10): x[-1].append(j)
Answer
Correct Answer: x = [[i for i in range(10)] for j in range(5)]
Explanation:
Note: This Question is unanswered, help us to find answer for this one