What is a simple list comprehension (without using any new modules or dictionary) to get output as below:
[1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
Here the number of 0s between each 1s increases from 0 to 10 times.
Without using list comprehension I got the output using simple for loops:
for i in range(12):
if i==0:
print(1, end=", ")
else:
for j in range(i):
if i==j+1:
print(1, end=", ")
else:
print(0, end=", ")
Just wanted to see how these loops can be converted to list comprehension