최대 1 분 소요

Python

import re
def solution(new_id):
    answer = new_id.lower()
    answer = re.sub('[^a-z0-9-_.]', '',answer)
    answer = re.sub('[\.]+', '.', answer)
    answer = answer.strip('.')
    if answer =='':
        answer='a'
    answer = answer[:15].rstrip('.')
    answer += answer[-1] * (3 - len(answer))
        
    return answer

댓글남기기