Let's say I have a list of elements X and one of indices Y.
X = [1, 2, 3, 4, 5, 6, 7]
Y = [0, 3, 4]
Is there a function in Python that allows one to extract elements from X based on the indices provided in Y? After execution, X would be:
X = [1, 4, 5]