I need to define a function apply(L, P) where L is a list and P is a permutation, and it should return the list L o P. Assume len(L) = len(P)
What I've got so far is
import itertools
def apply(L, P):
for perm in L:
return perm
An example of input is apply(['ah', 'boo', 'cc', 'du', 'eh'], [1, 4, 3, 2, 0])
But the only output from that is 'ah'
Any help would be great.
returnwill immediately end the function and return the value as the only return value. So you are essentially stopping your loop there. You might want to make it a generator instead and useyield.