[level 1] 이상한 문자 만들기
python 풀이
def solution(s):
ans_li=s.split(" ")
for i in range(len(ans_li)):
ans=list(ans_li[i])
for j in range(len(ans)):
if j%2==0:
ans[j]=ans[j].upper()
else:
ans[j]=ans[j].lower()
ans_li[i]="".join(ans)
return " ".join(ans_li)
def solution(s):
answer = []
for i in s.split():
result = ''
for n,v in enumerate(i):
if n%2 == 0:
result += v.upper()
else:
result += v.lower()
answer.append(result)
return ' '.join(answer)
댓글남기기