Get the number of iteration in for i in array

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By estebanmolca
var my_array=[]; for i in range(5): my_array.append(my_sprite);

for sp in my_array:	
	print(sp) #print name of instances of my_sprite but		
	#i need to get number of iteration, like: 
for sp in range(my_array.size()):
    print(sp) #print: 0 1 2 3 4
	

I want get number of iteration in the form for i in some_array:

is this possible? Or do I have to implement a counter? As:

iter+=1 print(iter)
:bust_in_silhouette: Reply From: volzhs
for i in range(my_array.size()):
    var sp = my_array[i]
    printt(i, sp.name)

I think this is best option.

Good idea! The correct thing would be something like sp.number_of_iteration but this works the same. Thanks for answering.

estebanmolca | 2019-05-30 13:39