It keeps flashing :(

I am new to all is coding so i am looking for some help please. I have this code (which i go from examples) which makes the LED high 3 seconds after you have pressed and released the button, for 3 seconds. The LED then continues to flash every 3 seconds. I would like i to stop after the first flash but also be trigger again when the button it pressed and released. Could anyone please help.

const int  buttonPin = 2;   
const int ledPin = 8;      
int buttonPushCounter = 0;   
int buttonState = 0;        
int lastButtonState = 0;     

void setup() {
  // initialize the button pin as a input:
  pinMode(buttonPin, INPUT);
  // initialize the LED as an output:
  pinMode(ledPin, OUTPUT);
  // initialize serial communication:
void loop() { 

  buttonState = digitalRead(buttonPin);

  if (buttonState != lastButtonState) {
    if (buttonState == LOW) {
      Serial.print("number of button pushes:  ");
    else {
  lastButtonState = buttonState;

  if (buttonPushCounter % 2 == 0)
    digitalWrite(ledPin, LOW);
  } else {
    // time before purge
    delay (3000);
    digitalWrite(ledPin, HIGH);
    // time purges for
    delay (3000);
    digitalWrite(ledPin, LOW); 

I can add he "while (1);" to stop it but it will not start again when the button is pushed and released. Confused.

Instead of testing for odd or even, test for 0. When the switch is released, set the value to 0. After flashing the LED, make sure it is off and set counter to 1. From then on, loop() won't flash the LED until you press the switch again.

Thanks I will try and see if I can do this.