Last answered:

28 Dec 2023

Posted on:

25 Dec 2023


Resolved: Understanding rolling sum & variable of increment

For below function, I can't understand why we created a variable Total to equal zero & why we further increment it by 1. Our aim is to count existing numbers less than 20 so what is the necessity of growing the total by 1.

def  count(numbers):


       for x in numbers:

             if x<20:


      return total

1 answers ( 1 marked as helpful)
Posted on:

28 Dec 2023


Hi Asmaa!
Thanks for reaching out.

The variable total is initialized to 0 and is used to keep track of the count of numbers less than 20. Each time a number in the list numbers is found to be less than 20, the total variable is incremented by 1 to reflect this count.

Hope this helps.

Submit an answer