Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[just-stopyoon] programmers_같은 숫자는 싫어_Python #10

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def solution(arr):
answer = []
answer.append(arr[0])
Comment on lines +2 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
answer = []
answer.append(arr[0])
answer = [arr[0]]

결국 동일한 의미이지만 저는 이렇게 초기화를 해주어서 이렇게 할 수도 있을 것 같아 남겨둡니다 ㅎㅎ

for num in arr : # 어차피 첫 번째 숫자는 같은 숫자이므로 push가 안되니 처음부터 진행
if num == answer[-1] : # 같은 숫자라면
continue # 넘어감
else : # 다른 숫자라면
answer.append(num) # 추가
return answer