

나의 코드
def solution(s):
answer = 0
while True:
if len(s) == 0:
break
x = s[0]
x_count = 0
other_count = 0
for i in range(len(s)):
if i == len(s)-1:
s=''
break
if s[i] == x:
x_count += 1
if x_count == other_count:
s=s[i+1:]
break
elif s[i] != x:
other_count += 1
if other_count == x_count:
s=s[i+1:]
break
answer += 1
print(answer)
return answer
solution("abracadabra")
'코딩테스트 파이썬 > 파이썬 프로그래머스 1단계' 카테고리의 다른 글
| [카카오 인턴] 키패드 누르기 (0) | 2023.05.22 |
|---|---|
| 크레인 인형뽑기 게임 (0) | 2023.05.21 |
| 완주하지 못한 선수 (0) | 2023.05.21 |
| 옹알이 (2) (1) | 2023.05.21 |
| 체육복 (0) | 2023.05.21 |