You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mutable/immutable 차이에 따른 메소드 작성 가이드가 PEP에 정의되어 있는지는 확인이 필요할 것 같습니다. 다만, 기본적으로는 말씀하신대로 str은 immutable이므로 in-place 수정이 불가능합니다. 값을 return 하는 것 외에는 변경된 값을 전달할 수 있는 방법이 없습니다. 물론 이렇게 되면 추가적인 공간 복잡도가 필요하게 되므로 가능하기만 하다면 리스트 처럼 in-place 수정이 가장 좋겠습니다.
리턴 여부는 함수 작성자가 결정할 문제이므로 이 방식이 PEP에 정의되어 있는 공식 가이드 인지는 확인이 필요할 것 같습니다.
안녕하세요! 1번 2번 문제를 풀면서 궁금한 점이 생겨 질문드립니다.
1번 문제를 풀다가 str 타입의 객체는 .lower() 같은 메소드를 사용했을 때 원본이 변하지 않는 것을 확인했고
2번 문제를 풀다가 list 타입의 객체에서는 .reverse()를 사용했을 때 원본이 변하는 것을 확인했습니다.
이렇게 객체의 메소드를 호출했을 때 원본이 변하냐 변하지 않느냐는 mutable / immutable 차이 때문에 발생하는 건가요?
The text was updated successfully, but these errors were encountered: