record
에 있는 요소들을 순회하면서 사용자 정보를 사전 자료형에 저장하거나 수정한다.record
에 있는 요소들을 순회하면서 각 상황에 맞는 메세지를 answer
에 담는다.def solution(records):
answer = []
user_info = dict()
# 1.
for record in records:
record = record.split()
if record[0] == "Enter":
user_info[record[1]] = record[2]
elif record[0] == "Change":
user_info[record[1]] = record[2]
# 2.
for record in records:
record = record.split()
if record[0] == "Enter":
answer.append(user_info[record[1]] + "님이 들어왔습니다.")
elif record[0] == "Leave":
answer.append(user_info[record[1]] + "님이 나갔습니다.")
return answer