Ask coding questions

← Back to all posts
Can you guys help me resolving this question?
RomeoRel (0)

Here is the question: Create a function named divisible_by_ten() that takes a list of numbers named nums as a parameter.

Return the count of how many numbers in the list are divisible by 10.
My answer should be correct but I got it wrong. I always got 2 as an output. I didn't know why.
Need your help guys!

InvisibleOne (2674)

Ok, first off there are a few issues in your code. Line is giving you two because it is checking how many characters are in a number, and since the first number is 20, it gives you two. You should change that line to i+=1
Second, below that you are returning the answer before the loop has finished, unindent return i two tabs.

RomeoRel (0)

@InvisibleOne Thank you so much. I don't know why I was overthinking it. I need to pay more attention to indentation. :)

InvisibleOne (2674)

np, sometimes you just need another set of eyes on something @RomeoRel

PrettyKenobi (1)

Are you sure that return is happening at the right time in the function? Since it's indented twice, it happens the first time your if statement is true.


everything seems to be working