I need this function to return True if all of the numbers of list_1 can be divisible by at least one number in list_2. I tried to use the all function for this like :
for num1 in list_1:
if all(num1 % num2 == 0 for num2 in list_2)
return True
The problem with my solution is that it checks if ALL the numbers in list_1 can be divisible by ALL the numbers in list_2, and that is not what I require.
I'm wondering if there is a way to do it such that all the numbers of list_1 have atleast one factor in list_2? An example would be:
List_1 = [15, 10, 4, 8, 12] List_2 = [2, 5, 3] output True
List_1 = [15, 10, 7, 8, 12] List_2 = [2, 5, 3] output False
It is False in the 2nd situation as 7 can't be divided by any of the numbers in list_2.