Hy! I have problem to solve this problem. Can anyone helps me?? Thanks!
#Write a function that moves all elements of one type to the end of the list.
def move_to_end(lst,el):
lst.append(lst.pop(lst.index(el)))
return lst
print(move_to_end([1, 3, 2, 4, 4, 1], 1))
print(move_to_end([7, 8, 9, 1, 2, 3, 4], 9))
print(move_to_end([“a”, “a”, “a”, “b”], “a”))
for the 3-rd one it doesn’t work. I don’t know how to develop other solution for this problem.
And why for the first and second it works but for the 3-rd one it doesn’t work?