add() 메서드는 집합에 요소를 추가합니다.
요소가 이미 있는 경우 add() 메서드는 요소를 추가하지 않습니다.
매개변수 | 필수 | 설명 |
---|---|---|
elmnt | 필수 | 집합에 추가할 요소 |
thisset = {"apple", "banana", "cherry"} thisset.add("orange") print(thisset)
결과
{'orange', 'cherry', 'apple', 'banana'}
thisset = {"apple", "banana", "cherry"} thisset.add("apple") print(thisset)
결과
{'banana', 'cherry', 'apple'}
© 2022 pinfo. All rights reserved.