[seungbinpark] programmers_같은 숫자는 싫어_Python - #19
Open
seungbinpark wants to merge 1 commit into
Open
Conversation
seungbinpark
requested review from
jaejunmin408,
just-stopyoon,
mingxoxo and
sangkyu39
January 19, 2025 17:34
mingxoxo
approved these changes
Jan 24, 2025
Comment on lines
6
to
13
Member
There was a problem hiding this comment.
else 값을 사용하지 않고 if 문 안에서 x를 초기화해도 가능할 것 같아요!
그리고 x를 두지 않고 ans[-1] 값과 비교하는 방법도 좋을 것 같습니다 ~~!
Suggested change
| for i in arr: | |
| #앞과 다르면 추가 | |
| if i != x: | |
| ans.append(i) | |
| print(i) | |
| else: | |
| continue | |
| x=i #x값 초기화 | |
| for i in arr: | |
| #앞과 다르면 추가 | |
| if i != x: | |
| ans.append(i) | |
| x=i #x값 초기화 |
just-stopyoon
approved these changes
Jan 26, 2025
just-stopyoon
left a comment
Contributor
There was a problem hiding this comment.
깔끔한 풀이인 것 같습니다!
정민님께서 언급하신 것처럼, else로 굳이 구분하지 않아도, 알아서 해당 조건에 맞지 않을 경우, continue 되기에 해당 부분은 생략해도 될 것 같아요 !
수고하셨습니다 :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 문제 링크
https://school.programmers.co.kr/learn/courses/30/lessons/12906
💡 풀이 아이디어
📝 새로 학습한 내용
-다른 사람 코드
빈 리스트에서 [-1:]을 사용하면 오류가 나지 않고 빈 리스트 []를 반환한다. 따라서, 리스트가 비어 있어도 안전하게 동작한다.
📚 참고 자료