0

Whats a different between append and insert in python

30th Nov 2017, 8:46 AM
ali karegaran
ali karegaran - avatar
3 ответов
+ 3
its simple 1.append adds elements at end of a list 2.insert uses index to insert elements in a list a=[1,2,3] a.append(7) print a #[1,2,3,7] a.insert(1,10) #(index,value) print a #[1,10,2,3,7] and a.insert(len(a),x) is same as a.append(x)
30th Nov 2017, 9:16 AM
Pavan Kumar T S
Pavan Kumar T S - avatar
+ 30
What programming language?
30th Nov 2017, 8:58 AM
Igor Makarsky
Igor Makarsky - avatar
+ 1
its so simple append adds element at the end of the list whereas insert adds the element in particular position which you specify👊😊
30th Nov 2017, 9:38 AM
Sreekar Siddula
Sreekar Siddula - avatar