Scope of variable in for loop

I am trying to number of images created by a module as define by loop.length value

i trying th following:

<div id=“a”>
{% for item in module.image_gallery %}
{% set no_Images = loop.length %}
<img src=“{{ item.src }}” alt=“{{ item.alt }}” >

<h3>Loop length with loop = {{ no_Images }}</h3>
{% endfor %}

</div>

<h3>Loop length outside of loop= {{ no_Images }}</h3>

But i dont seem to be able to get the value outide of the loop

for now i using jquery to find the length;

var imgCount = $(“img”).length;

try:

Loop length outside of loop {{ module.image_gallery|length }}

thankls john