https://programmers.co.kr/learn/courses/30/lessons/42888
def solution(record):
answer = []
nicknames = dict()
# for문을 돌면서 id에 대해 가장 최신의 닉네임을 딕셔너리로 저장
for txt in record:
if txt[0] == "E" or txt[0] == "C":
status, uid, nickname = txt.split()
nicknames[uid] = nickname
# 다시 for문을 돌면서 Enter, Leave에 대한 메세지를 answer에 추가
for txt in record:
if txt[0] == "E":
status, uid, nickname = txt.split()
answer.append(nicknames[uid] + "님이 들어왔습니다.")
elif txt[0] == "L":
status, uid = txt.split()
answer.append(nicknames[uid] + "님이 나갔습니다.")
return answer