https://school.programmers.co.kr/learn/courses/30/lessons/72410
신규아이디 추천
def solution(new_id):
new_id = new_id.lower() #1단계
alphabet = "abcdefghijklmnopqrstuvwxyz1234567890-_."
for i in new_id: #2-1단계
if not i in alphabet:#2-2단계
new_id = new_id.replace(i,"") #2-3단계
while ".." in new_id: #3-1단계
new_id = new_id.replace("..",".") #3-2단계
if new_id != "" and new_id[0] == ".": #4-1단계
new_id = new_id[1:] #4-2단계
if new_id != "" and new_id[-1] ==".": #4-1단계
new_id = new_id[:-1] #4-2단계
if new_id == "": #5-1단계
new_id="a" #5-2단계
if len(new_id) > 15: #6-1단계
new_id = new_id[:15] #6-2단계
if new_id[-1] ==".":
new_id = new_id[:-1] #6-3단계
while len(new_id) < 3: #7-1단계
new_id += new_id[-1] #7-2단계
return new_id
7단계를 모두 거치기 전에 new_id가 ""이 되어도 오류가 나지 않도록 할 것!