Inside a rendering variant I added a template. Inside that I want a for each loop. Can anyone please suggest if it's feasible. Sitecore 9.2
As you mention 9.2 we can assume this is a NVelocity template. As Vlad mentioned, you can use a foreach loop there as shown here: http://people.apache.org/~henning/velocity/html/ch05s04.html
<ul> #foreach( $product in $allProducts ) <li>$product</li> #end </ul>
Note however that 9.2 is the last version that support NVelocity - and it usually is not such a good idea to put too much logic inside a NVelocity template.