Lesson 20 of 34
Sets: फक्त अद्वितीय Values
7 min 25 XP
Set मध्ये तीच value कधीच दोनदा नसते. List मधले duplicates काढण्याचा सर्वात सोपा मार्ग 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() वापरा.