Skip to content
Advertisement

finding and replacing elements in a multidimensional list (python)

Similar to this question: finding and replacing elements in a list (python) but with a multi-dimensional array. For example, I want to replace all the N’s with 0’s:

JavaScript

I want to change it to:

JavaScript

Advertisement

Answer

You can use a nested list comprehension:

JavaScript

Output:

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