Hello, how do I change the value of a number in an array when I do not know what its index and can there be more than one value to change? For example, if I have the array:
[[4,5,3,15,4],
[20,17,3,4,56],
[5,6,2,90,32],
[18,7,1,8,13],
[0,20,30,4,7]]
And I want all values that are less than or equal to 4 to be changed to 10, how do I? Specifically a repeat structure, since the array may have different size depending on the case. I tried to do it as follows:
lista = [[4,5,3,15,4],
[20,17,3,4,56],
[5,6,2,90,32],
[18,7,1,8,13],
[0,20,30,4,7]]
numero <= 4
if numero in lista:
lista[lista.index(4)] = 10
print (lista)
However, the repeat structure does not work ... The output should be:
[[10,5,10,15,10],
[20,17,10,10,56],
[5,6,10,90,32],
[18,7,10,8,13],
[10,20,30,10,7]]