STUDY/Algorithm

[프로그래머스] LEVEL1 같은숫자는 싫어, python3

sinawi95 2019. 10. 15. 11:57
728x90

def solution(arr):
    answer = []
    # [실행] 버튼을 누르면 출력 값을 볼 수 있습니다.
    for i in range(len(arr)-1):
        if arr[i]!=arr[i+1]:
            answer.append(arr[i])
        if i==len(arr)-2:
            answer.append(arr[i+1])
    return answer