1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import collections company = input() input = list(map(str,input().split( ', ' ))); res=[] nameDic={} for value in input: name = list(map(str, value.split())); last = name[len(name)-1].replace( '-' , '' ) lastfirst = last.lower() + name[0][0].lower() cnt = int (nameDic.get(lastfirst, '0' )) finalName=lastfirst if cnt > 0 : finalName = finalName + str(cnt+1) nameDic[lastfirst] = cnt+1 tmp=[] tmp.append(finalName) tmp.append( "@" ) tmp.append(company.lower()) tmp.append( ".com" ) res.append( '' .join(tmp)) #중복된 이메일은 뒤에 후속 숫자를 붙여준다. for i in range(len(res)-1): print( '{0}, ' .format(res[i]), end= '' ) print(res[len(res)-1]) |
input
MIDASIT
John Doe, Peter Parker, Mary Jane Watson-Parker, James Doe, John Elvis Doe, Jane Doe, Penny Parker
output
doej@midasit.com, parkerp@midasit.com, watsonparkerm@midasit.com, doej2@midasit.com, doej3@midasit.com, doej4@midasit.com, parkerp2@midasit.com
'BOJ > Python' 카테고리의 다른 글
[Python] 리스트 안에 중복된 원소의 개수 구하기 (0) | 2020.03.28 |
---|---|
[BOJ] 18258. 큐2 (0) | 2020.03.19 |
[BOJ] 1181. 단어 정렬 (0) | 2020.03.18 |
[BOJ] 1475. 방 번호 (0) | 2020.03.18 |
[BOJ] 4949. 균형잡힌 세상 (0) | 2020.03.18 |