CBSE Class 11 Informatics Practices Question 54 of 80

Lists in Python — Question 17

Back to all questions
17
Question

Question 12

Differentiate between append() and insert() methods of list.

Answer
Insert MethodAppend Method
The insert() method is used to add an element at a specific index in the list.The append() method is used to add an element at the end of the list.
The syntax is: list.insert(index, element).The Syntax is: list.append(element).
Example: my_list.insert(2, 'hello') will insert the string 'hello' at index 2 in the list my_list.Example: my_list.append('world') will add the string 'world' at the end of the list my_list.