Plz help me. How i can use users input to make a list. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Plz help me. How i can use users input to make a list.

.

11th Mar 2021, 8:18 AM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
6 Answers
+ 5
First of all, please give a tag which is related to your question and topic, instead of '.' . append() function is used to insert the number or string at last index of list . For eg , >>>li = [1,2] >>>li [1,2] >>>li.append(3) >>>li [1,2,3] >>>li.append([1,2,3]) >>>li [1,2,3,[1,2,3]] etc.. So, first create an empty list then decide how much number you wanna insert inside list. Then use any loop for taking input till your range use append() for adding and after your loop block will complete then you will get a list whose elements are your input which you have given. https://code.sololearn.com/cNdcQraGis1a/?ref=app
11th Mar 2021, 8:40 AM
Abhiyantā
Abhiyantā - avatar
+ 1
L=[ ] n=int(input('Enter a range:')) for i in range(n): a=input() #or int(input()) l.append(a)
11th Mar 2021, 8:23 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ be sure that variable which is passed in range function is a integer not a string
11th Mar 2021, 8:33 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
0
What exactly you are looking to do ? Any example input and output you can give?
11th Mar 2021, 8:22 AM
Abhay
Abhay - avatar
0
AKSHAY🇮🇳 that's what i do. But the debugger finds an error in the range
11th Mar 2021, 8:29 AM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
0
AKSHAY🇮🇳 i'll try it. Thanks
11th Mar 2021, 8:35 AM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar