Newbie issue

Hi, I can't make this work.
What I want to do is turn a led on with a press of a button and then turn it off with another press.

const int but = 2;
const int led = 5;
int state = 0;
int stateLast = 0;

void setup() {
  // put your setup code here, to run once:
pinMode(but, INPUT);
pinMode(led, INPUT);
Serial.begin(9600);
}

void loop() {
  state = digitalRead(but);
  
    if (state == HIGH && stateLast == LOW){
      digitalWrite (led, HIGH);
      
   
  }
  else if (state == HIGH && stateLast == HIGH){
    digitalWrite (led, LOW);
  }
  
 stateLast = state;
 delay(100);   


}

What I want to do is turn a led on with a press of a button and then turn it off with another press.

Well, you have our permission to do that.

Posting code without explaining how the hardware is connected and what the code does, and how that differs from what you want, is rather pointless.

If you want current to go OUT to the LED, declaring the pin as an INPUT pin is probably not the best approach.