converting output to list | Sololearn: Learn to code for FREE!

0

converting output to list

Sample Input: 10 Sample Output: [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480] n = int(input()) N = 0 while(N<12): print(n) n = n+n N = N + 1 i want to get output as a list

4/16/2021 8:17:45 AM

ռɛɛʟᏦǟռƭ ֆɨռɢʟǟ

3 Answers

New Answer

+5

If I edit your code a bit then it can be done by using a list: https://code.sololearn.com/ca218a258a14 Here is an example using list comprehension: https://code.sololearn.com/c4a4A15a10A1

+2

n=int(input()) l=[n*(2**(i-1)) for i in range(1,13)] print(l) #this is an old problem with the prize for the chess creator

+1

you would need to create a list and append, or use list comprehension, or use list() with an iterable.