https://programmers.co.kr/learn/courses/30/lessons/42888
def rebuild(s):
result = []
if len(s.split())>2:
info = list(map(str,s.split()))
else:
info = list(map(str,s.split()))
info.append(info[1])
return info
def check(records):
info = {}
for record in records:
if (record[0] == "Enter") or (record[0]=="Change"):
info[record[1]] = record[2]
return info
def print_answer(record,info):
answer = []
for record_split in record:
if record_split[0] == "Enter":
answer.append("{}님이 들어왔습니다.".format(info[record_split[1]]))
elif record_split[0] == "Leave":
answer.append("{}님이 나갔습니다.".format(info[record_split[1]]))
return answer
def solution(record):
answer = []
records=[]
for s in record:
records.append(rebuild(s))
info=check(records)
answer=print_answer(records,info)
return answer