I have a doubt.

I had a list like this

[['Varun', 19.0], ['Kakunami', 19.0], ['Harsh', 20.0], ['Beria', 20.0],
['Vikas', 21.0]]

I am using a for loop to del the rows with the lowest value like this:

for row in marks:
    if row[1] == lowest:
        marks.remove(row)

But after running this loop, I get the following:

[['Kakunami', 19.0], ['Harsh', 20.0], ['Beria', 20.0], ['Vikas', 21.0]]

If I print row for every iteration one row is missed in the iteration. Here
is the output.

['Varun', 19.0]
['Harsh', 20.0]
['Beria', 20.0]
['Vikas', 21.0]

If I use list comprehensions, I get the right output. I just want to
understand what is happening. Can anyone help me out here?

This if from an hackerrank assignment.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to