0

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, but I can't find any mention of a method to entirely remove a list element from a list.

Basically, I want to remove a row from a table, this is the code I'm working with;

employeeTable = [[2, 4, 3, 4, 5, 8, 8], [7, 3, 4, 3, 3, 4, 4], [3, 3, 4, 3, 3, 2, 2],
                 [9, 3, 4, 7, 3, 4, 1], [3, 5, 4, 3, 6, 3, 8], [3, 4, 4, 6, 3, 4, 4],
                 [3, 7, 4, 8, 3, 8, 4], [6, 3, 5, 9, 2, 7, 9]]
highestValue = 0
highestEmployee = 0

while employeeTable:
    for i in range(len(employeeTable))
        if sum(employeeTable[i]) > highestValue:
            highestValue = sum(employeeTable[i])
            highestEmployee = i
    print("Employee " + highestEmployee + " has " + highestValue + " hours this week.")

And after each for loop finishes, I would like to remove one of the 8 rows from the list and loop again. I am aware that I can probably pop the top row from the list, but I am more trying to figure out if there is a way to remove a specific row instead.

Rekka
  • 11
  • 1
  • 1

1 Answers1

1

As Stephen Rauch mentioned, you can just use

del employeeTable[<row to delete>]

And if you want to remove an element within a row, it would be

del employeeTable[<row of element>][<position of element in row>]

Jack Brown
  • 23
  • 5