오픈 채팅방 - python(programmers)

참치돌고래·2021년 8월 30일
0

알고리즘

목록 보기
17/36
post-custom-banner

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
profile
안녕하세요
post-custom-banner

0개의 댓글