Stuck in an infinite loop


I tried that but i don’t know if i have to use a while loop but anyway the count doesn’t stop to 3…

def divisible_by_ten(nums):
count = 0
while count <= len(nums):
for num in nums:
if num % 10 == 0:
count += 1
return count

This will result in an infinite loop since the length of the list never changes. You have a for loop that iterates the list and checks each value for divisibility by 10. That is all you need.

Thanks Roy, I changed it and it worked !

1 Like