Iterative/foreach loop possible?

I’m new to development and I just wanted to ask if this is a simple soltion and if so get some guidance.
Can I use huggingface api for an iterative loop through?
Lets say i have the same prompt that i want ask in different ways that are preset for instance:
why does tom like

why does tom like red
why does tom like blue
etc
the preset values would be red, blue
so the last part would be a variable that needs to change.

in powershell this terminology would be a foreach loop.

any ideas how to get this done with hugging face please, possible?