Programming | Python | Reference | Resources
Python List, Tuple, Set, and Dictionary Methods Reference
Last Updated on May 11, 2026 by Admin
| Index | Type | Method | Description | Example |
|---|---|---|---|---|
| 1 | list [] | __add__ | Combines two lists using + | [1,2] + [3,4] |
| 2 | list [] | __class__ | Returns the object’s class/type | x.__class__ |
| 3 | list [] | __class_getitem__ | Supports generic type hints | list[int] |
| 4 | list [] | __contains__ | Checks if value exists in list | 2 in [1,2,3] |
| 5 | list [] | __delattr__ | Deletes an attribute | del obj.attr |
| 6 | list [] | __delitem__ | Deletes item at index | del x[0] |
| 7 | list [] | __dir__ | Lists object attributes/methods | dir(x) |
| 8 | list [] | __doc__ | Returns documentation string | list.__doc__ |
| 9 | list [] | __eq__ | Checks equality using == | [1]==[1] |
| 10 | list [] | __format__ | Formats object output | format(x) |
| 11 | list [] | __ge__ | Greater than or equal comparison | [2] >= [1] |
| 12 | list [] | __getattribute__ | Retrieves an attribute | x.__getattribute__(‘append’) |
| 13 | list [] | __getitem__ | Accesses item by index | x[0] |
| 14 | list [] | __getstate__ | Returns state for pickling | x.__getstate__() |
| 15 | list [] | __gt__ | Greater than comparison | [2] > [1] |
| 16 | list [] | __hash__ | Returns hash value | hash(tuple(x)) |
| 17 | list [] | __iadd__ | Adds in-place using += | x += [4] |
| 18 | list [] | __imul__ | Multiplies in-place using *= | x *= 2 |
| 19 | list [] | __init__ | Initialises object | list() |
| 20 | list [] | __init_subclass__ | Customises subclass creation | class A(list): pass |
| 21 | list [] | __iter__ | Returns iterator | iter(x) |
| 22 | list [] | __le__ | Less than or equal comparison | [1] <= [2] |
| 23 | list [] | __len__ | Returns length | len(x) |
| 24 | list [] | __lt__ | Less than comparison | [1] < [2] |
| 25 | list [] | __mul__ | Multiplies list using * | [1]*3 |
| 26 | list [] | __ne__ | Checks inequality | [1] != [2] |
| 27 | list [] | __new__ | Creates new instance | list.__new__(list) |
| 28 | list [] | __reduce__ | Used for pickling | x.__reduce__() |
| 29 | list [] | __reduce_ex__ | Advanced pickling support | x.__reduce_ex__(4) |
| 30 | list [] | __repr__ | Official string representation | repr(x) |
| 31 | list [] | __reversed__ | Returns reverse iterator | reversed(x) |
| 32 | list [] | __rmul__ | Right-side multiplication | 3 * [1] |
| 33 | list [] | __setattr__ | Sets attribute value | obj.attr = 1 |
| 34 | list [] | __setitem__ | Sets item by index | x[0] = 5 |
| 35 | list [] | __sizeof__ | Returns memory size | x.__sizeof__() |
| 36 | list [] | __str__ | User-friendly string output | str(x) |
| 37 | list [] | __subclasshook__ | Custom subclass checking | list.__subclasshook__(A) |
| 38 | list [] | append | Adds item to end | x.append(4) |
| 39 | list [] | clear | Removes all items | x.clear() |
| 40 | list [] | copy | Creates shallow copy | x.copy() |
| 41 | list [] | count | Counts occurrences | x.count(2) |
| 42 | list [] | extend | Adds multiple items | x.extend([4,5]) |
| 43 | list [] | index | Returns item index | x.index(2) |
| 44 | list [] | insert | Inserts item at index | x.insert(0,99) |
| 45 | list [] | pop | Removes and returns item | x.pop() |
| 46 | list [] | remove | Removes first matching item | x.remove(2) |
| 47 | list [] | reverse | Reverses list | x.reverse() |
| 48 | list [] | sort | Sorts list | x.sort() |
| 49 | tuple () | __add__ | Combines tuples | (1,2)+(3,4) |
| 50 | tuple () | __class__ | Returns object’s class | t.__class__ |
| 51 | tuple () | __class_getitem__ | Supports type hints | tuple[int] |
| 52 | tuple () | __contains__ | Checks if item exists | 2 in t |
| 53 | tuple () | __delattr__ | Deletes attribute | del obj.attr |
| 54 | tuple () | __dir__ | Lists attributes/methods | dir(t) |
| 55 | tuple () | __doc__ | Returns documentation | tuple.__doc__ |
| 56 | tuple () | __eq__ | Equality comparison | (1)==(1) |
| 57 | tuple () | __format__ | Formats output | format(t) |
| 58 | tuple () | __ge__ | Greater/equal comparison | (2,) >= (1,) |
| 59 | tuple () | __getattribute__ | Retrieves attribute | t.__getattribute__(‘count’) |
| 60 | tuple () | __getitem__ | Accesses item by index | t[0] |
| 61 | tuple () | __getnewargs__ | Supports pickling | t.__getnewargs__() |
| 62 | tuple () | __getstate__ | Returns object state | t.__getstate__() |
| 63 | tuple () | __gt__ | Greater than comparison | (2,) > (1,) |
| 64 | tuple () | __hash__ | Returns hash value | hash(t) |
| 65 | tuple () | __init__ | Initialises object | tuple() |
| 66 | tuple () | __init_subclass__ | Custom subclass creation | class A(tuple): pass |
| 67 | tuple () | __iter__ | Returns iterator | iter(t) |
| 68 | tuple () | __le__ | Less/equal comparison | (1,) <= (2,) |
| 69 | tuple () | __len__ | Returns length | len(t) |
| 70 | tuple () | __lt__ | Less than comparison | (1,) < (2,) |
| 71 | tuple () | __mul__ | Repeats tuple | (1,2)*2 |
| 72 | tuple () | __ne__ | Inequality comparison | (1,) != (2,) |
| 73 | tuple () | __new__ | Creates new object | tuple.__new__(tuple) |
| 74 | tuple () | __reduce__ | Used for pickling | t.__reduce__() |
| 75 | tuple () | __reduce_ex__ | Advanced pickling support | t.__reduce_ex__(4) |
| 76 | tuple () | __repr__ | Official representation | repr(t) |
| 77 | tuple () | __rmul__ | Right multiplication | 2 * (1,) |
| 78 | tuple () | __setattr__ | Sets attribute | obj.attr = 1 |
| 79 | tuple () | __sizeof__ | Returns memory size | t.__sizeof__() |
| 80 | tuple () | __str__ | User-friendly output | str(t) |
| 81 | tuple () | __subclasshook__ | Subclass checking | tuple.__subclasshook__(A) |
| 82 | tuple () | count | Counts occurrences | t.count(2) |
| 83 | tuple () | index | Returns item index | t.index(2) |
| 84 | set {} | __and__ | Returns intersection using & | {1,2} & {2,3} |
| 85 | set {} | __class__ | Returns object’s class | s.__class__ |
| 86 | set {} | __class_getitem__ | Supports type hints | set[int] |
| 87 | set {} | __contains__ | Checks if item exists | 2 in s |
| 88 | set {} | __delattr__ | Deletes attribute | del obj.attr |
| 89 | set {} | __dir__ | Lists methods/attributes | dir(s) |
| 90 | set {} | __doc__ | Returns documentation | set.__doc__ |
| 91 | set {} | __eq__ | Equality comparison | {1} == {1} |
| 92 | set {} | __format__ | Formats output | format(s) |
| 93 | set {} | __ge__ | Greater/equal comparison | {1,2} >= {1} |
| 94 | set {} | __getattribute__ | Retrieves attribute | s.__getattribute__(‘add’) |
| 95 | set {} | __getstate__ | Returns object state | s.__getstate__() |
| 96 | set {} | __gt__ | Greater than comparison | {1,2} > {1} |
| 97 | set {} | __hash__ | Returns hash value | hash(frozenset(s)) |
| 98 | set {} | __iand__ | In-place intersection | s &= t |
| 99 | set {} | __init__ | Initialises object | set() |
| 100 | set {} | __init_subclass__ | Custom subclass creation | class A(set): pass |
| 101 | set {} | __ior__ | In-place union | s |= t |
| 102 | set {} | __isub__ | In-place subtraction | s -= t |
| 103 | set {} | __iter__ | Returns iterator | iter(s) |
| 104 | set {} | __ixor__ | In-place symmetric difference | s ^= t |
| 105 | set {} | __le__ | Less/equal comparison | {1} <= {1,2} |
| 106 | set {} | __len__ | Returns length | len(s) |
| 107 | set {} | __lt__ | Less than comparison | {1} < {1,2} |
| 108 | set {} | __ne__ | Inequality comparison | {1} != {2} |
| 109 | set {} | __new__ | Creates new object | set.__new__(set) |
| 110 | set {} | __or__ | Returns union using | | {1}|{2} |
| 111 | set {} | __rand__ | Reverse intersection | {1}&s |
| 112 | set {} | __reduce__ | Used for pickling | s.__reduce__() |
| 113 | set {} | __reduce_ex__ | Advanced pickling | s.__reduce_ex__(4) |
| 114 | set {} | __repr__ | Official representation | repr(s) |
| 115 | set {} | __ror__ | Reverse union | {1}|s |
| 116 | set {} | __rsub__ | Reverse subtraction | {1,2}-{2} |
| 117 | set {} | __rxor__ | Reverse symmetric difference | {1}^s |
| 118 | set {} | __setattr__ | Sets attribute | obj.attr = 1 |
| 119 | set {} | __sizeof__ | Returns memory size | s.__sizeof__() |
| 120 | set {} | __str__ | User-friendly output | str(s) |
| 121 | set {} | __sub__ | Difference using – | {1,2}-{2} |
| 122 | set {} | __subclasshook__ | Subclass checking | set.__subclasshook__(A) |
| 123 | set {} | __xor__ | Symmetric difference using ^ | {1}^{2} |
| 124 | set {} | add | Adds item | s.add(5) |
| 125 | set {} | clear | Removes all items | s.clear() |
| 126 | set {} | copy | Creates shallow copy | s.copy() |
| 127 | set {} | difference | Returns differences | a.difference(b) |
| 128 | set {} | difference_update | Removes common items | a.difference_update(b) |
| 129 | set {} | discard | Removes item safely | s.discard(2) |
| 130 | set {} | intersection | Returns common items | a.intersection(b) |
| 131 | set {} | intersection_update | Keeps common items only | a.intersection_update(b) |
| 132 | set {} | isdisjoint | Checks no common items | a.isdisjoint(b) |
| 133 | set {} | issubset | Checks subset | a.issubset(b) |
| 134 | set {} | issuperset | Checks superset | a.issuperset(b) |
| 135 | set {} | pop | Removes random item | s.pop() |
| 136 | set {} | remove | Removes item | s.remove(2) |
| 137 | set {} | symmetric_difference | Returns non-common items | a.symmetric_difference(b) |
| 138 | set {} | symmetric_difference_update | Updates with non-common items | a.symmetric_difference_update(b) |
| 139 | set {} | union | Combines sets | a.union(b) |
| 140 | set {} | update | Adds items from another set | a.update(b) |
| 141 | dict{} | __class__ | Returns object’s class | d.__class__ |
| 142 | dict{} | __class_getitem__ | Supports type hints | dict[str,int] |
| 143 | dict{} | __contains__ | Checks if key exists | ‘a’ in d |
| 144 | dict{} | __delattr__ | Deletes attribute | del obj.attr |
| 145 | dict{} | __delitem__ | Deletes key/value pair | del d[‘a’] |
| 146 | dict{} | __dir__ | Lists methods/attributes | dir(d) |
| 147 | dict{} | __doc__ | Returns documentation | dict.__doc__ |
| 148 | dict{} | __eq__ | Equality comparison | {‘a’:1} == {‘a’:1} |
| 149 | dict{} | __format__ | Formats output | format(d) |
| 150 | dict{} | __ge__ | Greater/equal comparison | d1 >= d2 |
| 151 | dict{} | __getattribute__ | Retrieves attribute | d.__getattribute__(‘keys’) |
| 152 | dict{} | __getitem__ | Accesses value by key | d[‘a’] |
| 153 | dict{} | __getstate__ | Returns object state | d.__getstate__() |
| 154 | dict{} | __gt__ | Greater than comparison | d1 > d2 |
| 155 | dict{} | __hash__ | Returns hash value | hash(frozenset(d.items())) |
| 156 | dict{} | __init__ | Initialises object | dict() |
| 157 | dict{} | __init_subclass__ | Custom subclass creation | class A(dict): pass |
| 158 | dict{} | __ior__ | In-place merge using |= | d |= {‘b’:2} |
| 159 | dict{} | __iter__ | Returns iterator | iter(d) |
| 160 | dict{} | __le__ | Less/equal comparison | d1 <= d2 |
| 161 | dict{} | __len__ | Returns number of items | len(d) |
| 162 | dict{} | __lt__ | Less than comparison | d1 < d2 |
| 163 | dict{} | __ne__ | Inequality comparison | {‘a’:1} != {‘b’:2} |
| 164 | dict{} | __new__ | Creates new object | dict.__new__(dict) |
| 165 | dict{} | __or__ | Merges dictionaries using | | d1 | d2 |
| 166 | dict{} | __reduce__ | Used for pickling | d.__reduce__() |
| 167 | dict{} | __reduce_ex__ | Advanced pickling support | d.__reduce_ex__(4) |
| 168 | dict{} | __repr__ | Official representation | repr(d) |
| 169 | dict{} | __reversed__ | Returns reverse iterator | reversed(d) |
| 170 | dict{} | __ror__ | Reverse merge | d2 | d1 |
| 171 | dict{} | __setattr__ | Sets attribute | obj.attr = 1 |
| 172 | dict{} | __setitem__ | Sets key/value pair | d[‘a’]=1 |
| 173 | dict{} | __sizeof__ | Returns memory size | d.__sizeof__() |
| 174 | dict{} | __str__ | User-friendly output | str(d) |
| 175 | dict{} | __subclasshook__ | Subclass checking | dict.__subclasshook__(A) |
| 176 | dict{} | clear | Removes all items | d.clear() |
| 177 | dict{} | copy | Creates shallow copy | d.copy() |
| 178 | dict{} | fromkeys | Creates dictionary from keys | dict.fromkeys([‘a’,’b’]) |
| 179 | dict{} | get | Safely retrieves value | d.get(‘a’) |
| 180 | dict{} | items | Returns key/value pairs | d.items() |
| 181 | dict{} | keys | Returns keys | d.keys() |
| 182 | dict{} | pop | Removes key and returns value | d.pop(‘a’) |
| 183 | dict{} | popitem | Removes last inserted item | d.popitem() |
| 184 | dict{} | setdefault | Returns value or inserts default | d.setdefault(‘a’,0) |
| 185 | dict{} | update | Updates dictionary | d.update({‘a’:1}) |
| 186 | dict{} | values | Returns values | d.values() |