Get The Most Affordable Hosting in the World!
Starting at just $1.87/month, Vercaa offers unbeatable pricing for world-class web hosting services.
Fast, reliable, and secure hosting to power your website without breaking the bank. Plus, enjoy a free CDN for faster loading times worldwide!
Get Started Now!There are two methods of the list class, append() and insert(), that are used to add items to an existing list.
Example 1
The append() method adds the item at the end of an existing list.
Output
It will produce the following output −
Original list: ['a', 'b', 'c', 'd'] List after appending: ['a', 'b', 'c', 'd', 'e']
Example 2
The insert() method inserts the item at a specified index in the list.
Output
It will produce the following output −
Original list ['Rohan', 'Physics', 21, 69.75] List after appending: ['Rohan', 'Physics', 'Chemistry', 21, 69.75] List after appending: ['Rohan', 'Physics', 'Chemistry', 21, 'Pass', 69.75]
We know that "-1" index points to the last item in the list. However, note that, the item at index "-1" in the original list is 69.75. This index is not refreshed after appending 'chemistry'. Hence, 'Pass' is not inserted at the updated index "-1", but the previous index "-1".
The End! should you have any inquiries, we encourage you to reach out to the Vercaa Support Center without hesitation.