
input = ["any", "albany", "apple", "baby", ""]

output = []       # Initialize output

for x in input:
   if len(x) == 0:   # Protect illegal access of x[0] and x[-1]
      continue 
   if x[0] != "a":
      continue
   if x[-1] != "y":
      continue
   output.append(x)

print(output)

