How to make list from input user,example.If i input 3,output is [1,2,3] and when u input 2 after 3,result is [2,4,6].Like that | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to make list from input user,example.If i input 3,output is [1,2,3] and when u input 2 after 3,result is [2,4,6].Like that

list in python

11th Nov 2016, 11:53 AM
omi
2 Answers
+ 1
There is more than one way to get that output given that input; this code does it: x = int(input("?")); res = [i for i in range(1,x+1)]; print(res); y =int(input("?")); res2 = [y*i for i in res]; print(res2);
11th Nov 2016, 12:52 PM
Marco
0
The complete question like this : Make script infinite loop whom accept iteration number from input user and make output array list with structure like this : $ python script.py input: 3 [1, 2, 3] input: 2 [2, 4, 3] input: 6 [3, 6, 6, 4, 5, 6] input: 1 [4, 6, 6, 4, 5, 6] input: 1 [5, 6, 6, 4, 5, 6]
12th Nov 2016, 2:33 PM
omi