- 2
Give me idea how can i solve this simple programme.
Problem and my code is given below https://www.sololearn.com/coach/1101?ref=app
5 Respostas
+ 1
Md Abu Taher List comprehension is a concept in Python. You have to read about how to use it. It replace an ordinary for loop. (You can of course solve your problem with an ordinary for loop, but this wasn’t really the task, was it? Nope, the task was to learn how to use list comprehensions.)
+ 3
Well, that's a pro content non-pros can't access that.
You have to give some description of the task and share your attempt so someone from the community can help
//are you on pro? your profile doesn't confirm that
+ 1
Try use list comprehension. The formula is in the task:
number_of_insects * 2 ** month
The number of insectes comes from input(). The number of month you have to specify as an exceeding list, or a range(), like [0, 1, 2, …, 11]. Then put it an comprension list:
[f(i) for i in <container>].
Thats all, and he output will be a list with 12 element, where the inputwd value will double for every month.
+ 1
Daljeet Singh
My code
n = int(input())
for i in range(0,12):
print(n*(2**i))
+ 1
Per Bratthammar
Yes i understand it but i can not put the output in list.
my code:
n = int(input())
for i in range(0,12):
print(n*(2**i))