Skip to content
Advertisement

Delete columns of a nested list with list comprehension

How would I write this for loop as a list comprehention?

This is the list:

JavaScript

I want to delete row 4 and 5

JavaScript

I did try this but it just gives me a syntax error

JavaScript

Any idea how to do that with a list comprehension?

Advertisement

Answer

You can slice the list upto index 3:

JavaScript

If that is what you want.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement