Linked Questions

26 votes
1 answer
49k views

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 ...
user3768495's user avatar
  • 4,717
7 votes
4 answers
24k views

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() ...
user avatar
0 votes
1 answer
9k views

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, ...
Rekka's user avatar
  • 11
0 votes
1 answer
2k views

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 (...
Kjc21793's user avatar
-4 votes
1 answer
885 views

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], ...
Felipe Corrales Vargas's user avatar
2 votes
1 answer
804 views

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: ...
noona mun's user avatar
0 votes
1 answer
451 views

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 ...
Trenera's user avatar
  • 1,515
-2 votes
3 answers
492 views

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)``` ...
NIKEN's user avatar
  • 19
-2 votes
1 answer
336 views

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. ...
steelscape02's user avatar
0 votes
1 answer
235 views

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: ...
Rachel FG's user avatar
0 votes
1 answer
193 views

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 ...
Crypticlaugh's user avatar
1 vote
1 answer
75 views

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]...
Debbie's user avatar
  • 969
0 votes
2 answers
130 views

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: '...
Theooc's user avatar
  • 31
0 votes
0 answers
127 views

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 ...
shirayyyy's user avatar
0 votes
1 answer
86 views

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 ...
Alias's user avatar
  • 3

15 30 50 per page
1
2 3 4 5