Hi guys,
I’m sure i’m going about it it the wrong way but if anyone can give me insights into what’s happening with the code, i’d greatly appreciate it.
From my understanding, my code (at the bottom) should iterate through the entire list however it seems to stop after the first one, can anyone advise as to why (or if it’s doing anything else)?
def divisible_by_ten(nums):
count = 0
for number in nums:
if (number % 10 == 0):
count += 1
return count
#Write your function here
def divisible_by_ten(num):
count1 = len(num)
print(count1)
for numbers in list(range((count1))):
print(list(range(count1)))
print(num)
if num[numbers]%10!=0:
continue
new_list =[ ]
new_list.append(num[numbers])
print(new_list)
return len(new_list)
#Write your function here
def divisible_by_ten(nums):
list = []
for num in nums:
if num % 10 == 0:
list.append(num)
return len(list)
#Uncomment the line below when your function is done
print(divisible_by_ten([20, 25, 30, 35, 40]))
Could someone explain to me if this is an advisable solution to this code challenge