Python Code Challenges: Loops Nr. 1

**Hi there everyone! :slight_smile: **

I have a brief questions regarding challenge nr. 1 in Python Code Challenges (Optional). The challenges asks you to create a loop through a list and only return those divisible by ten. I failed multiple time at a single step, namely:

In the solution there is onlye extra step added before returning the count/list, which is count =+1. Can someone explain to me why this needs to be added and why I get an error, if it is not included? Thank you all very much in advance <3
Screenshot 2022-08-25 at 10.49.08

I don’t know the exact text of the challenge. But based on the screenshot you posted, the argument/input being passed to the function is a list. The function isn’t supposed to return the list of numbers which are divisible by 10. Instead, the function is supposed to return how many numbers of the list are divisible by 10.
e.g. divisible_by_ten([1, 10, 60, 5, 8, 90, 3]) should return 3 because there are three numbers in the list that are divisible by ten.
count += 1 is equivalent to count = count + 1
It is necessary to increase the count by one every time a perfectly divisible number is observed. Once the loop finishes, the count is returned.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.