Python List Comprehension | Sololearn: Learn to code for FREE!

+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

1/11/2022 9:15:01 PM

Adewale Obalanlege

7 Answers

New Answer

+3

Course: Python Data Structures 11.2 Pratice Insect Control I have no access to this PRO lesson module. Can you share here the required inputs and expected outputs of this Code Practice please? It would help us in pointing out the errors. I don't know if this would work but shouldn't 13 be 12?

+2

I have solved it. n = int(input()) double_n = [n*2**i for i in range(12)] print(double_n)

+2

Thank you 😊

+1

https://sololearn.com/coach/1101/?ref=app

+1

Sorry I can't view the link, I am not PRO subscribed user.

+1

Yes that was it. Great.

0

n = int(input()) double_n = [2*n**i for i in range(12)] print(double_n)