Linked Questions
61 questions linked to/from How to remove an element from a list by index
26 votes
1 answer
49k views
Remove an item in list and get a new list? [duplicate]
I saw there are several topics on removing items from a list, including using remove(), pop(), and del. But none of these is what I am looking for, since I want to get a new list when the items are ...
7 votes
4 answers
24k views
Python: Remove a single entry in a list based on the position of the entry [duplicate]
Is there an easy way to delete an entry in a list? I would like to only remove the first entry. In every forum that I have looked at, the only way that I can delete one entry is with the list.remove() ...
0 votes
1 answer
9k views
Can I remove a list element from a two-dimensional list? [duplicate]
So I couldn't find any mention of this anywhere. Maybe I'm just looking for the wrong thing or the answer is so obvious that I just somehow missed it. I started working with two-dimensional arrays, ...
0 votes
1 answer
2k views
Delete Item from specific location in list in Python [duplicate]
I'm writing a statistics program which will maintain a list of float values. The program will implement the following menu: Add value to list Delete value from list (by value) Delete value from list (...
-4 votes
1 answer
885 views
Python. Delete rows from matrix without Numpy [duplicate]
so I have this matrix: matrix = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] And I want to remove the last row, so it return me something like this: matrix = [ [1, 2, 3], ...
2 votes
1 answer
804 views
How to assign "empty" to a list position (Python) [duplicate]
I'm trying to modify my listt: listt = [[1, 4], [11, 24], [11123, 6624], [3, 4]] lvl = 11 n = 50 for z in listt: if z[0]==lvl: if z[1] > n: z[1]=n elif z[1] < n: ...
0 votes
1 answer
451 views
How to delete elements from a list in a dictionary [duplicate]
I have a dictionary, result, with lists in it. In one of the lists ("Failure"), its elements can be equal to 1, 2 or 3. If for example element number 9 is equal to 3 (or 1), I want to delete each ...
-2 votes
3 answers
492 views
method removes 2 arguments, but should only be 1 [duplicate]
I am trying to make a method which will remove item from list, but when I am trying to choose which one I want remove I get error (TypeError: rent() takes 1 positional argument but 2 were given)``` ...
-2 votes
1 answer
336 views
How to remove all items at a specified index in a nested list python [duplicate]
I have a list that contains some stuff similar to the below entry: [[1, 'Potato', 2, 'Bag'], [2, 'Banana, 1, 'Bunch']]. These elements represent in order the item's UPC, Name, Quantity, and unit type. ...
0 votes
1 answer
235 views
How do I remove an element in a list at a specific index using a variable in Python? [duplicate]
My program uses this variable: questionNum = random.randint(0,9) Later in the program I tried to remove an element in the list by doing this: questionList.remove([questionNum]) I got this error: ...
0 votes
1 answer
193 views
How do I delete strings from a list in a certain order without typing its value? [duplicate]
I already know how to delete strings, but the question here is: How do you delete them in a certain order without typing its value, for example, "Mathew", but I want to remove it without actually ...
1 vote
1 answer
75 views
How can I delete all elements from a list from a particular elemen in the list? [duplicate]
i have a list like below: myList = [3, 5, 7, 2, 100, 76] I want to delete all the elements from the list starting with the element 2, i.e., after deletion the list should like this: myList = [3, 5, 7]...
0 votes
2 answers
130 views
Is there alternative way to do it? [duplicate]
Is there alternative way to do it without using function pop ? Input :a_list = [1,2,3,4,5,6,7] a_list.pop(1) Output : a_list = [1,3,4,5,6,7] I have tried something but it says TypeError: '...
0 votes
0 answers
127 views
How to remove object element when objects collide? [duplicate]
I'm new to programming and currently taking a fundamental course with zero prior knowledge. My team's current project is to program a game in python. It is a remake of the classic snake game where you ...
0 votes
1 answer
86 views
Python not in list [duplicate]
I am new to programming and am trying to code a simple calculator. The code takes user input, generates a list of numbers and operators (eg. 1+2/3*4) and loops over the list to perform the calculation ...