tutorial
- Python References Tutorial
- Python References
- built-in
- Python built-in Method - import()
- Python built-in Method - abs()
- Python built-in Method - all()
- Python built-in Method - any()
- Python built-in Method - ascii()
- Python built-in Method - bin()
- Python built-in Method - bool()
- Python built-in Method - bytearray()
- Python built-in Method - bytes()
- Python built-in Method - callable()
- Python built-in Method - chr()
- Python built-in Method - classmethod()
- Python built-in Method - compile()
- Python built-in Method - complex()
- Python built-in Method - delattr()
- Python built-in Method - dict()
- Python built-in Method - dir()
- Python built-in Method - divmod()
- Python built-in Method - enumerate()
- Python built-in Method - eval()
- Python built-in Method - exec()
- Python built-in Method - filter()
- Python built-in Method - float()
- Python built-in Method - format()
- Python built-in Method - frozenset()
- Python built-in Method - getattr()
- Python built-in Method - globals()
- Python built-in Method - hasattr()
- Python built-in Method - hash()
- Python built-in Method - help()
- Python built-in Method - hex()
- Python built-in Method - id()
- Python built-in Method - input()
- Python built-in Method - int()
- Python built-in Method - isinstance()
- Python built-in Method - issubclass()
- Python built-in Method - iter()
- Python built-in Method - len()
- Python built-in Method - list()
- Python built-in Method - locals()
- Python built-in Method - map()
- Python built-in Method - max()
- Python built-in Method - memoryview()
- Python built-in Method - min()
- Python built-in Method - next()
- Python built-in Method - object()
- Python built-in Method - oct()
- Python built-in Method - open()
- Python built-in Method - ord()
- Python built-in Method - pow()
- Python built-in Method - print()
- Python built-in Method - property()
- Python built-in Method - range()
- Python built-in Method - repr()
- Python built-in Method - reversed()
- Python built-in Method - round()
- Python built-in Method - set()
- Python built-in Method - setattr()
- Python built-in Method - slice()
- Python built-in Method - sorted()
- Python built-in Method - staticmethod()
- Python built-in Method - str()
- Python built-in Method - sum()
- Python built-in Method - super()
- Python built-in Method - tuple()
- Python built-in Method - type()
- Python built-in Method - vars()
- Python built-in Method - zip()
- dictionary
- Python dictionary Method - clear()
- Python dictionary Method - copy()
- Python dictionary Method - fromkeys()
- Python dictionary Method - get()
- Python dictionary Method - items()
- Python dictionary Method - keys()
- Python dictionary Method - pop()
- Python dictionary Method - popitem()
- Python dictionary Method - setdefault()
- Python dictionary Method - update()
- Python dictionary Method - values()
- list
- Python list Method - append()
- Python list Method - clear()
- Python list Method - copy()
- Python list Method - count()
- Python list Method - extend()
- Python list Method - index()
- Python list Method - insert()
- Python list Method - pop()
- Python list Method - remove()
- Python list Method - reverse()
- Python list Method - sort()
- set
- Python set Method - add()
- Python set Method - clear()
- Python set Method - copy()
- Python set Method - difference()
- Python set Method - difference_update()
- Python set Method - discard()
- Python set Method - intersection()
- Python set Method - intersection_update()
- Python set Method - isdisjoint()
- Python set Method - issubset()
- Python set Method - issuperset()
- Python set Method - pop()
- Python set Method - remove()
- Python set Method - symmetric_difference()
- Python set Method - symmetric_difference_update()
- Python set Method - union()
- Python set Method - update()
- string
- Python string Method - capitalize()
- Python string Method - casefold()
- Python string Method - center()
- Python string Method - count()
- Python string Method - encode()
- Python string Method - endswith()
- Python string Method - expandtabs()
- Python string Method - find()
- Python string Method - format()
- Python string Method - format_map()
- Python string Method - index()
- Python string Method - isalnum()
- Python string Method - isalpha()
- Python string Method - isdecimal()
- Python string Method - isdigit()
- Python string Method - isidentifier()
- Python string Method - islower()
- Python string Method - isnumeric()
- Python string Method - isprintable()
- Python string Method - isspace()
- Python string Method - istitle()
- Python string Method - isupper()
- Python string Method - join()
- Python string Method - ljust()
- Python string Method - lower()
- Python string Method - lstrip()
- Python string Method - maketrans()
- Python string Method - partition()
- Python string Method - replace()
- Python string Method - rfind()
- Python string Method - rindex()
- Python string Method - rjust()
- Python string Method - rpartition()
- Python string Method - rsplit()
- Python string Method - rstrip()
- Python string Method - split()
- Python string Method - splitlines()
- Python string Method - startswith()
- Python string Method - strip()
- Python string Method - swapcase()
- Python string Method - title()
- Python string Method - translate()
- Python string Method - upper()
- Python string Method - zfill()
- tuple
- Python tuple Method - count()
- Python tuple Method - index()
Python list Method - clear()
httsp://www.theitroad.com
The clear()
method in Python is a built-in method used to remove all the elements from a list.
Syntax:
list_name.clear()
Example:
my_list = [1, 2, 3, 4] my_list.clear() print(my_list) # Output: []
The clear()
method modifies the original list and does not return anything. It is useful when we want to remove all the elements from a list. If we want to remove a specific element from the list, we can use the remove()
method or use slicing to remove a range of elements from the list.