How to add element in Python to the end of list using list.insert?
list.insert with any index >= len(of_the_list) places the value at the end of list. It behaves like append
Python 3.7.4>>>lst=[10,20,30]>>>lst.insert(len(lst), 101)>>>lst[10, 20, 30, 101]>>>lst.insert(len(lst)+50, 202)>>>lst[10, 20, 30, 101, 202]
Time complexity, append O(1), insert O(n)