person = [
    ["Baha", "enter"],
    ["Askar", "enter"],
    ["Baha", "leave"],
    ["Artem", "enter"]
]

answer = []

for i in range(len(person)):
    if person[i][1] == "enter":
        answer.append(person[i][0])
    elif person[i][1] == "leave":
        if person[i][0] in answer:
            answer.remove(person[i][0])

answer.sort(reverse=True)

print(answer)

Embed on website

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