from collections import deque

commands = ["E 민수", "E 지환", "D", "E 하은", "D", "E 소윤"]
answer = []
queue = deque()

for i in range(len(commands)):
    if commands[i][0] == "E":
        answer.append(commands[i])
    elif commands[i] == "D":
        answer.pop(0)
        
print(answer)

Embed on website

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