Arduino Lighthouse

Okay so I'll try to be as clear as I can. I have a momentary push button on pin 2 which is pulled down to ground. I have an LED on analog pin 0 and a servo on pin 9. What I want to happen is that when the arduino is powered on it begins checking the state. If a button press is detected it want the arduino to turn the LED on pin 2 on and also to begin sweeping the servo back and forth between 0 and 180. Then if the button is pressed again i want the LED to turn off and the servo to stop moving.
My understanding of what the code 'should' be doing is this; on power up the arduino checks the state of the button and stores this value in the buttonState variable. After the first time through the loop it also stores the state of the button for the previous time through the loop in the prevButtonState variable. When the button is pressed the value of buttonState is high, however the value of PrevButtonState is low (or vice versa). This information is used to count button presses and store the value in the pushCount variable. An if statement is then used to check if the value of pushCount is even or odd. If pushCount is even then the LED on pin 2 should be set high and the servo position should be set to the value of servoPos which is determined by the for loops. if the value of pushCount is odd the the LED should be set low and the servo should be set to 90 degrees using servo.write.

I have the code working with the LED, each time I push the button the LED goes on or off per button press. However, if I add the code to write the servo positions the whole program does nothing. There is no error but nothing works.

This is my most up to date code:

#include<Servo.h>  // Include servo library

const int button = 2; // Button is attached to pin 2
const int led = A0; // LED is on pin A0

Servo servo;  // Create a servo object

int pushCount = 0; // Declare a variable to hold number of button pushes
int buttonState = 0;  // Variable holds present state of button
int prevButtonState = 0;  // Variable holds previous button state
int servoPos = 0; // Variable stores the position of the servo

void setup() {
  servo.attach(9); // Servo on pin 9
  pinMode(button, INPUT); //  // Declare button (pin 2) as input
  pinMode(led, OUTPUT); // Declare LED (pin A0) as output
}

void loop() {
  buttonState = digitalRead(button); // Set the value of buttonState to the current value of button
  if(buttonState != prevButtonState) { // If button state if not the same as the prevButtonState ...
    if(buttonState == HIGH) { // And if buttonState is high
      pushCount++; // Increment pushCount value
    }
    delay(20);  // Wait 20ms
  }
  prevButtonState = buttonState; // Save current state of button as previous button state
  
  if(pushCount % 2 == 0) {  // If the value of pushCount is an even number
    for(servoPos=0; servoPos <=180; servoPos++) { // For loop sweeps value servoPos from 0 to 180
       servo.write(pos); // Write the value servoPos to the servo on pin 9
       delay(10); // Wait 10ms
    }
    for(servoPos=180; servoPos>=0; servoPos--) {  // For loop sweeps value the other way - I.e. from 180 to 0
       servo.write(pos);
       delay(10); // wait another 10ms
    }
    digitalWrite(led, ); // Turn LED on
  }
  else {  // Else if pushCount is NOT an even number
    digitalWrite(led, LOW);  // Turn LED off
    
    prevButtonState = buttonState;
  }
}

I think my problem might be that the arduino can't run the main loop to keep checking for button presses whilst also running the for loops to write servo positions.

Again, any help is massively appreciated. Bella has done such an incredible job making the light house out of paper mache and painting it, I would hate to not my part of it done on time.