l1 = ['apple', 'pear', 'grapes', 'banana']
target_element = 'pear'
try:
    target_index = l1.index(target_element) + 1
except ValueError as e:
    target_index = None
l1[:target_index]
Remove all elements from a list after a particular value