lst = input().split()
lst.pop(0)
w = lst[-1]
lst.pop(-1)
newlst = [int(x) for x in lst if int(x) <= int(w)]
print(newlst)
This works for me. Best of luck.
4.6m questions
6.0m answers