+ 2
Python List Comprehension
The number of insects in a lab doubles in size every month. Take the initial number of insects as input and output a list, showing the number of insects for each of the next 12 months, starting with 0, which is the initial value. So, the resulting list should contain 12 items, each showing the number of insects at the beginning of that month. n= int(input)) d = [n**I for I in range(n - 1, 13)] print(d) I got the test case 1 but the test case 2 output empty list
4 Answers
+ 3
I have solved it.
n = int(input())
double_n = [n*2**i for i in range(12)]
print(double_n)
+ 3
Thank you đ
0
n = int(input())
double_n = [2*n**i for i in range(12)]
print(double_n)