Start by getting rid of the delay(50). That's going to mess up anything else that you might want to do with this code in the future.
void loop() {
static unsigned long lastPrinted;
const unsigned long printInterval = 50; //milliseconds, how often to print
if(millis() - lastPrinted >= printInterval) {
printLowPins();
lastPrinted = millis();
}
//any other code can go here and it gets run very rapidly
}
Now we can take your code above and put it into the printLowPins() function I just imagined. You said that you always want it to print something, just a single 'S' if there's no pins low at all?
void printLowPins() {
bool nothingPrinted= true;
for(int i = 0; i <= 10; i++){
if (digitalRead(i) != true){
Serial.println(i);
nothingPrinted= false;
}
}
if(nothingPrinted) {
Serial.println("S");
}
}
Note: you may want to change .println() to .print() to put it on one line like your example.