python 3 dunded methods code example
Example 1: list methods python
list.append(x) # append x to end of list
list.extend(iterable) # append all elements of iterable to list
list.insert(i, x) # insert x at index i
list.remove(x) # remove first occurance of x from list
list.pop([i]) # pop element at index i (defaults to end of list)
list.clear() # delete all elements from the list
list.index(x[, start[, end]]) # return index of element x
list.count(x) # return number of occurances of x in list
list.reverse() # reverse elements of list in-place (no return)
list.sort(key=None, reverse=False) # sort list in-place
list.copy() # return a shallow copy of the list
Example 2: function in python 3
# A basic function
def func():
return 0
# A function with arguments
def func2(num1):
return num1
# A function with type hints
def func3(num2: int) -> int:
return num2