Suppose I have two lists, one containing customer name and other containing product name.
Customer = [ ‘Harry’, ‘Aisha’, ‘Neha’, ‘Ahmed’]
Product = [ ‘Shoe’, ‘Brush’, ‘Pen’, ‘Laptop’, ‘Noodles’]
I have learnt two methods of list, append
and extend
. As both are used to add items.
Customer.append(‘Kareem’)
Product.extend(‘Book’)
Both are working fine. Why do we need two different methods for adding items to a list? Are these methods the same? What key feature creates the difference between these two?