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 Antworten
+ 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.