Skip to content
Advertisement

Python edhesive 10.4

I’ve tried posting this question onto other websites and I have received, lightly to say, little to no feedback that helps. This is the question at hand: Image Here

The code is asking to divide the numbers in a 2d array by 3, and if they’re not divisible by 3, then return them to a 0 in the array. This is the current code I have:

JavaScript

The divide (divSUM) returns as nothing. and I’m unsure if numpy would work, every time I try it says its outdated so I assume it doesn’t. Any help would be nice, but I’m mainly having issues with putting the undivisble by 3 numbers to a 0.

Advertisement

Answer

(What I understood is that if the number % 3 == 0 you let the same number otherwise you put 0.)

I propose to work with numpy it’s easy to do it in a simple line :

JavaScript

Otherwise, the problem with your code is that you wrongly choose the place where to put return. So, you have to do this:

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