logs = [
    ["ryan", "OFF"], 
    ["neo", "OFF"], 
    ["ryan", "ON"], 
    ["muzi", "OFF"]
]

answer = []

for i in range(len(logs)):
    if logs[i][1] == "OFF":
        answer.append(logs[i][0])
    else:
        if logs[i][0] in answer:
            answer.remove(logs[i][0])

answer.sort()

print(answer)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: