How to organize dynamic use of for?

You must pass all elements of the array with a step of 2, but the number of elements is not known beforehand.
something like this:
#!/bin/bash
arr=([1]=1 [2]=2 3 [5]=4 5);
for i in {0..${#arr[*]}..2};do
 printf "[$i]:${arr[$i]}\n";
done

But the processing throws:
arr.sh line 4: {0..5..2}: syntax error: expected operand (error label "{0..5..2}")
June 3rd 19 at 19:39
1 answer
June 3rd 19 at 19:41
#!/bin/bash
arr=([1]=1 [2]=2 3 [5]=4 5);
eval 'for i in {0..'${#arr[*]}'..2};do
 printf "[$i]:${arr[$i]}\n";
done'

This brace expansion only works with literals. The solution generates the loop body literals and puts it in a eval.

Find more questions by tags Arraysbash