Use list comprehension
with re.findall, to find the elements in your list that start with "A":
import re
fruit_lst = ["Apple", "Banana", "Pear", "Apricot", "Orange"]
filtered_lst = [s for s in fruit_lst if re.findall(r'^A', s)]
print(filtered_lst)
# ['Apple', 'Apricot']
Note that this method allows you to easily extend the code to other related functionalities, such as to find elements that start with "a" in case-insensitive way:
fruit_lst = ["Apple", "Banana", "Pear", "Apricot", "Orange", "apple"]
filtered_lst = [s for s in fruit_lst if re.findall(r'^a', s, re.IGNORECASE)]
print(filtered_lst)
# ['Apple', 'Apricot', 'apple']
Or those that have "p" anywhere, case-insensitive:
fruit_lst = ["Apple", "Banana", "Pear", "Apricot", "Orange", "apple"]
filtered_lst = [s for s in fruit_lst if re.findall(r'p', s, re.IGNORECASE)]
print(filtered_lst)
# ['Apple', 'Pear', 'Apricot', 'apple']
x if x[0]=="A"isn't a valid expression. What's the value if it's not equal to A? Probably you just wanted to return the condition itself to be used to filter the list.elseclause.