FAQ: Code Challenge: Loops - Divisible by Ten


This community-built FAQ covers the “Divisible by Ten” exercise from the lesson “Code Challenge: Loops”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Computer Science

FAQs on the exercise Divisible by Ten

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!


When creating a function and extract a particular integer or string from the list, why is it necessary to create a new variable? Below is the code:

#Write your function here
def divisible_by_ten(nums):
count = 0
for number in nums:
if (number % 10 == 0):
count += 1
return count

#Uncomment the line below when your function is done
print(divisible_by_ten([20, 25, 30, 35, 40]))


count = 0

that’s where i get stuck


The loop is iterating values in the list. count is tracking their positions in the list, by index. Recall that lists are zero-indexed using positive integers (and zero) in sequence. The highest index is always one less than the length of the list.


Oh ok. I got it! Yes thank you


I’m not a native speaker and I’m oftenly answering wrong because the statement is not clear.

Return the amount of numbers in that list that are divisible by 10

That wasn’t clear for me and I was trying to sum everything


How’s this?

Return a count of the numbers in that list which are divisible by 10.