Lesson 20 of 34
Sets: सिर्फ़ अनोखे मान
7 min 25 XP
set में एक ही मान दो बार नहीं रहता। list से दोहराव हटाने का सबसे आसान तरीका set() है।
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.दो sets की तुलना: | (union) सब कुछ, & (intersection) जो दोनों में है, और - (difference) जो सिर्फ़ पहले में है।
Example: edit me and press Run
Output Loading Python (first time takes a few seconds)
Press Run to see the result here.Sets का कोई क्रम नहीं होता, इसलिए set[0] काम नहीं करता। क्रम चाहिए तो sorted() लगाएँ।