def solution(new_id):
#1단계
new_id = new_id.lower()
answer = ''
#2단계
for i in new_id:
if (i.isdigit() or i.isalpha() or i in ('-', '_', '.')):
answer += i
#3단계
while ('..' in answer):
answer = answer.replace('..', '.')
#4단계
answer = answer.strip('.')
#5단계
if (len(answer) == 0):
answer += 'a'
#6단계
if (len(answer) >= 16):
answer = answer[0:15]
answer = answer.strip('.')
#7단계
if (len(answer) <= 2):
while (len(answer) != 3):
answer += answer[-1]
return answer
문제에 나온 절차대로 진행함
def solution(new_id):
#1단계
new_id = new_id.lower()
answer = ''
#2단계
for i in new_id:
if (i.isdigit() or i.isalpha() or i in ('-', '_', '.')):
answer += i
#3단계
while ('..' in answer):
answer = answer.replace('..', '.')
#4단계
answer = answer.strip('.')
#5단계
if (answer == ''):
answer += 'a'
#6단계
if (len(answer) >= 16):
answer = answer[:15]
answer = answer.strip('.')
#7단계
if (len(answer) <= 2):
while (len(answer) != 3):
answer += answer[-1]
return answer