from machine import Pin
import time
led_pins = [21, 23, 19, 12]
key_pins = [18, 22, 5, 13]
states = [0, 0, 0, 0]
LEDs = [Pin(pin, Pin.OUT) for pin in led_pins]
KEYs = [Pin(pin, Pin.IN, Pin.PULL_UP) for pin in key_pins]
while True:
    for i, key in enumerate(KEYs):
        if key.value() == 0:
            time.sleep_ms(10)
            if key.value() == 0:
                states[i] = not states[i]
                LEDs[i].value(states[i])
        while not key.value():
            pass