0
Why this code wrong? I want to insert element in list
7 odpowiedzi
+ 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👍🏼
+ 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
0
Although Im not sure what you want to do😅
Could you please elaborate your question?
0
I want to create list from inputs and make iteration in index to put inputs in their places
0
For example?
0
Input____1 2 3 4 5
Result [1,2,3,4,5]
0
Thanks a lot