Simple while loop not working

I have just written the following sketch and am puzzled about result, any help much appreciated

int a =0;
void setup()
{
Serial.begin(9600);
}

void loop()
{
while (a<10)
{
Serial.print("a = ");
Serial.println(a);
a=a+1;
delay(1000);
}
}

the result on Serial is as follows

a = 0
a = 0
a = 1
a = 2
a = 3
a = 4
a = 5
a = 6
a = 7
a = 8
a = 9

why does a print 0 twice, can't find the logic to it?

Your code does not behave as you claim.

int a =0;
void setup()
{
  Serial.begin(250000);
}

void loop()
{
  while (a<10)
  {
    Serial.print("a = ");
    Serial.println(a);
    a=a+1;
    delay(1000);
  }
}
a = 0
a = 1
a = 2
a = 3
a = 4
a = 5
a = 6
a = 7
a = 8
a = 9

It doesn't.

Sometimes the Serial Monitor can display some input from the previous run of the sketch. It could be that the program ran up to the first print, the microcontroller reset, then it ran the full program.

It did , but on an arduino nano
Have now tried sketch like yourselves on Arduino uno and it works as expected
So this must a broken nano or Shannon is right (which is surprising because I've run so many successful sketches on it )
Was trying this sketch earlier

To Turn on led 1 to 5 in turn and reverse
*/

int d =200;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
for (int a =2; a<7 ; a++)
{
pinMode(a,OUTPUT);

}

}

// the loop function runs over and over again forever
void loop() {

for (int a =2; a<7 ; a++)
{

digitalWrite(a,HIGH);

delay(d);

digitalWrite(a,LOW);

delay(d);

}
for (int a =5; a>1 ; a--)
{

digitalWrite(a,HIGH);

delay(d);

digitalWrite(a,LOW);

delay(d);

}

//int a= 2;

}

which worked,

I have now disconnected nano from circuit and the while loop sketch is now working as expected. Must have had something to do with the connected components. I'll try again later to find problem component by deduction.

How can you work with your code in such a mess ?

Here it is Auto formatted in the IDE and in code tags

int d = 200;
// the setup function runs once when you press reset or power the board
void setup()
{
  // initialize digital pin LED_BUILTIN as an output.
  for (int a = 2; a < 7 ; a++)
  {
    pinMode(a, OUTPUT);
  }
}

// the loop function runs over and over again forever
void loop()
{
  for (int a = 2; a < 7 ; a++)
  {
    digitalWrite(a, HIGH);
    delay(d);
    digitalWrite(a, LOW);
    delay(d);
  }
  for (int a = 5; a > 1 ; a--)
  {
    digitalWrite(a, HIGH);
    delay(d);
    digitalWrite(a, LOW);
    delay(d);
  }
  //int a= 2;
}