In Java, we can change the counter variable of a for loop inside its header itself. See below:
for(int i=1; i<1024; i*=2){
System.out.println(i);
}
I know the following code is wrong. But is there a way to write like that without changing i value inside the loop. I like to make my for loop simple and short :-)
for i in range(1, 1024, i*=2):
print(i)
for i in (2**k for k in range(10))