for loop how to use index

i have created a for loop.
But i cannot find how to use the index on variables
Tried several + and other solution but without succes...

what am i doing wrong???

My code is:

  // read the pushbutton input pin:
  buttonState1 = digitalRead(sensor1);
  buttonState2 = digitalRead(sensor2);
  buttonState3 = digitalRead(sensor3);
  buttonState4 = digitalRead(sensor4);
  buttonState5 = digitalRead(sensor5);
  buttonState6 = digitalRead(sensor6);
  buttonState7 = digitalRead(sensor7);


for (int i=1; i <= 7; i++){

// sensor1
   if ((sensor + i) == HIGH ) {
        (buttonState + i ) = HIGH;
          } else {
            buttonStatei = LOW;
          }
            if (buttonStatei != lastButtonStatei) {  // compare the buttonState to its previous state
                 if (buttonStatei == HIGH) {
                    // wend from off to on:
                    client.publish(location,i"/on");
                    Serial.println(location,i"/on");
                    } else {
                    // wend from on to off:
                    client.publish(location,i"/off");
                    Serial.println(location,i"/off");
                    }
              delay(wait);  // Delay a little bit to avoid bouncing
              }
            lastButtonStatei = buttonStatei;   // save the current state as the last state,
       

}

For a start you haven't got a complete program that will compile.

And (sensor + i) won't do what I guess you think it's doing. Neither will (buttonstate + i) nor even buttonstatei

Look up arrays https://www.arduino.cc/en/Reference/Array and then start using them like it says.

Steve

When you are tempted to suffix variable names with numbers, it is time to learn about arrays.
When you are tempted to post code snippets, it is time to read THIS.

What everyone else said.

Arrays are a basic part of the C++ programming language. You probably need to google "C++ tutorial" and do a C++ tutorial, rather than cutting and pasting bits of sample code.