규칙에 따라 parsing
def solution(new_id):
answer = ''
for char in new_id:
if char.isalpha():
answer += char.lower()
elif char == '.' and answer and answer[-1] != '.':
answer += '.'
elif char.isdigit() or char in '-_':
answer += char
if not answer:
answer += 'a'
elif len(answer) > 15:
answer = answer[:15]
if answer[-1] == '.':
answer = answer[:-1]
while len(answer) < 3:
answer = answer + answer[-1]
return answer
'practivceAlgorithm > programmers' 카테고리의 다른 글
[Kakao2020][Python] 괄호 변환 (0) | 2021.10.24 |
---|---|
[programmers][Python] 2021 kakao blind 메뉴 리뉴얼 (0) | 2021.10.20 |
[Programmers][Python] 2021 kakaoblind 카드 짝 맞추기 (0) | 2021.10.17 |
[Programmers][Python] 퍼즐조각채우기 (0) | 2021.10.14 |
[Programers][Python] 부족한 금액 계산하기 (0) | 2021.10.09 |