I have a list m in python, and I want to remove all the elements in m that are not relatively prime to all previous elements. So if m=[2,3,4] I want the output to be [2,3].
I tried iterating through the values of m, but it doesnt work since the size of m changes and then the index value is out of range.