Add prefix to dataframe columns that match those names in a list

Use a comprehension:

columns_to_prefix = set(['fruit', 'colour', 'country'])
df.columns = [f"the_{c}" if c in columns_to_prefix else c for c in df.columns]
print(df)

# Output
  the_fruit the_colour popularity the_country  cost
0     Apple      Green       High          UK     2
1     Berry        Red       High       Spain     4