본문 바로가기
알고리즘/소스코드

PROGRAMMERS 42888: 오픈채팅방

by cjw.git 2021. 1. 13.

Link : programmers.co.kr/learn/courses/30/lessons/42888


Python

더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def solution(record):
    answer = []
    data = dict()
    for i in record:
        command_line = i.split(' ')
        if command_line[0!= 'Leave':
            command = command_line[0]
            uid = command_line[1]
            name = command_line[2]
            if command == 'Enter':
                answer.append(uid + '#님이 들어왔습니다.')
            data[uid] = name
        else:
            uid = command_line[1]
            answer.append(uid + '#님이 나갔습니다.')
    for idx, val in enumerate(answer):
        answer[idx] = data[val.split('#')[0]] + val.split('#')[1]
    return answer
cs

FeedBack

  1.  

 

 

 

cjw.git@gmail.com

댓글