0
Python list
How can I create a function that return the smallest number that is divisible by 3 from a list. Input [‘2’, ‘1’, ‘3’, ‘4’, ‘6’] Output = 3
2 Answers
+ 3
You could use list comprehension
b=[i for i in list if int(i)%3==0]
print(min(b))
+ 2
Here is the instructions you should follow :
1) Filter the elements of the list so that it only contains the elements which are divisible by 3!
2) Return the smallest number from the list.