Let's write a program that will read a positive integer n from the input and create a nested list containing the inner list [1, 2] repeated n times.
Use list comprehension and remember what arguments
range() takes.Let's write a program that will read a positive integer n from the input and create a nested list containing the inner list [1, 2] repeated n times.
range() takes.Sample Input 1:
5Sample Output 1:
[[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]Sample Input 2:
2Sample Output 2:
[[1, 2], [1, 2]]Create a free account to access the full topic