Skip to content
Advertisement

Nested FOR loops – coding challenge

I am learning python using STEPIK and I am facing this:

I want on every iteration of the inside for loop sum the values of predicted_growth list with the value of cases list, save it in some temporary variable and print it. Click on the link for the full challenge.

This is my code so far:

JavaScript

This is the output of the function I should be getting:

JavaScript

Instead I am getting this:

JavaScript

Advertisement

Answer

You can use a loop with an inner list comprehension.

JavaScript

Output

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