Question: Below is the code Use list comprehension to find the sum of all numbers that are divisable by 3 between and an upper limit n.

 Below is the code Use list comprehension to find the sum
Below is the code
of all numbers that are divisable by 3 between and an upper

Use list comprehension to find the sum of all numbers that are divisable by 3 between and an upper limit n. If you are struggling, write this in a more "traditional" format first and then convert it to list comprehension. You should update the function sum_div_ 3(n) so that it returns the correct sum. def sum_div_3( n ): "I" you should update div_by_3_list to generate the list of numbers div by 3 and return their sum. e.g. for n=10 it should look at 1,2,3,4,5,6,7,8,9,10 and the list should contain [3,6,9]. The function should then return the list sum, in this case 18 "n" div_by_3_list = [] return sum(div_by_3_list) if name__= "_main_" : print(sum_div_3(10)) print(sum_div_3(12)) print(sum_div_3(100))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!