aim is to write a function div_3() that will find all the values from the input parameter data_list that are perfectly divisible by 3, using a for loop with a conditional inside the function. And to save any values from data_list that meet this condition into a new list 'output', which is returned from the function.
data_list = [12, 49, 67, 308, 23, 15, 36, 21, 410]
def div_3(data_list):
output = []
for i in data_list:
if i % 3 == 0:
output.append(i)
else:
continue
print (output)
test:
div_3(data_list)
[12, 15, 36, 21]
assert type(div_3(data_list)) == list
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
/tmp/ipykernel_529/3718698975.py in <module>
1 div_3(data_list)
2
----> 3 assert type(div_3(data_list)) == list
AssertionError:
I'm not sure why the output prints as a list [], but when trying to assert type == list, it produces an error