0

Why this code wrong? I want to insert element in list

https://code.sololearn.com/c7ZLP59Mgz6T/?ref=app

30th May 2019, 6:34 PM
Ahmed Gamal
Ahmed Gamal - avatar
7 Respostas
+ 1
If you want to insert an element you could simply do this: myList = [1, 2, 3, 4] myList.append(5) If you only want unique elements in the list, yoi should use a set instead For example: mySet = {1, 2, 3} mySet.add(3) mySet.add(4) print(*mySet) >>> Outputs: 1 2 3 4 Message me if you need any more help👍🏼
30th May 2019, 6:46 PM
Trigger
Trigger - avatar
+ 1
1. #Input: any number list(range(1,int(input())) 2. # Input: 1 2 3 4 5 x = input() print(x.split()) 3. # Input: any number ls = [] for i in range(1, int(input())+1): ls.append(i) print(ls) There are more ways but the logic is the same
30th May 2019, 6:57 PM
Trigger
Trigger - avatar
0
Although Im not sure what you want to do😅 Could you please elaborate your question?
30th May 2019, 6:48 PM
Trigger
Trigger - avatar
0
I want to create list from inputs and make iteration in index to put inputs in their places
30th May 2019, 6:49 PM
Ahmed Gamal
Ahmed Gamal - avatar
0
For example?
30th May 2019, 6:50 PM
Trigger
Trigger - avatar
0
Input____1 2 3 4 5 Result [1,2,3,4,5]
30th May 2019, 6:51 PM
Ahmed Gamal
Ahmed Gamal - avatar
0
Thanks a lot
30th May 2019, 6:58 PM
Ahmed Gamal
Ahmed Gamal - avatar