📘 Lesson  ·  Lesson 80

List vs Tuple vs Set vs Dict

चार Collections

💡 एक नज़र में

Python में चार built-in collection types हैं। कब किसे use करें यह बहुत common interview question है।

तुलना Table

TypeOrderedChangeableDuplicatesSyntax
Listहाँहाँहाँ[1, 2, 3]
Tupleहाँनहींहाँ(1, 2, 3)
Setनहींहाँनहीं{1, 2, 3}
Dictहाँ (3.7+)हाँkeys नहीं{"a": 1}

Example

Python
my_list = [1, 2, 2, 3]      # duplicates allowed
my_tuple = (1, 2, 3)        # बदल नहीं सकते
my_set = {1, 2, 2, 3}       # duplicate हटाता है -> {1,2,3}
my_dict = {"name": "Aman"}  # key-value pairs
print(my_set)
{1, 2, 3}

सारांश

  • List = ordered, changeable, duplicates allowed।
  • Tuple = ordered, fixed। Set = unordered, unique। Dict = key-value।
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.