how to run to commands on one sketch (loop)

I am trying to program a sketch for the first time and wanted to make something like this void setup() { pinMode(6,OUTPUT); } void loop() { digitalWrite(6,HIGH); delay(400); digitalWrite(6,LOW); delay(700); } { pinMode(5,OUTPUT); } digitalWrite(5,HIGH); delay(700); digitalWrite(5,LOW); delay(400); }

Yet every time i check it it says expected unqualified-id before '{'

I'm a beginner so the answers is probably obvious

All this stuff is outside of setup or loop.

{
pinMode(5,OUTPUT);
}
digitalWrite(5,HIGH);
delay(700);
digitalWrite(5,LOW);
delay(400);
}

So this would make more sense

void setup() {
pinMode(6,OUTPUT);
pinMode(5,OUTPUT);
}
void loop() {
digitalWrite(6,HIGH);   
delay(400);
digitalWrite(6,LOW);
delay(700);

digitalWrite(5,HIGH);
delay(700);
digitalWrite(5,LOW);
delay(400);
}

In the IDE put the cursor to the right of a bracket or parentheses and the matching bracket or parentheses will be highlighted. This can help you match them up. If you do an auto format (Tools, autoformat) it will tell you if you have mismatched brackets.

void setup() {
    pinMode(6,OUTPUT);
}

void loop() {
    digitalWrite(6,HIGH);   
    delay(400);
    digitalWrite(6,LOW);
    delay(700);
}  // This is the end of the function called 'loop'

{ // This appears to be the start of a new function except it has no name or return type and both of those are required
    pinMode(5,OUTPUT);
}

// And here is some more code outside of any function (not allowed)
digitalWrite(5,HIGH);
delay(700);
digitalWrite(5,LOW);
delay(400);
}

Thanks for the help it now works