For loop overriding outer variables instead of creating new ones

Solution 1:

This is not the same. In C, you explicitly create a new variable, whereas in Python, you reuse the name in the for scope, ending up overriding the previous value.

So the C equivalent really is:

#include <stdio.h>

int main(void) 
{
  int x = 15;
  for (x = 0; x < 10; ++x)
  {
    continue;
  }
  --x; // To accommodate the different behavior of the range loop
  printf("%d", x);
  return 0;
}

Don't forget that in Python, variables are just entries in a dictionary, dynamically created, whereas in C, they are independent, static items.