{"id":24694,"date":"2021-10-25T09:07:07","date_gmt":"2021-10-25T03:37:07","guid":{"rendered":"https:\/\/python-programs.com\/?p=24694"},"modified":"2021-11-05T17:19:58","modified_gmt":"2021-11-05T11:49:58","slug":"python-list-append-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-list-append-method-with-examples\/","title":{"rendered":"Python List append() Method with Examples"},"content":{"rendered":"

In the previous article, we have discussed Python String islower() Method with Examples<\/a>
\nList in Python:<\/strong><\/p>\n

Lists in Python are mutable sequences. They are extremely similar to tuples, except they do not have immutability constraints. Lists are often used to store collections of homogeneous things, but there is nothing stopping you from storing collections of heterogeneous items as well.<\/p>\n

List append() Method in Python:<\/strong><\/p>\n

The append() method adds an element or item to the end of the list.<\/p>\n

Syntax:<\/strong><\/p>\n

list.append(item)<\/pre>\n

Parameters<\/strong><\/p>\n

The method only accepts one argument.<\/p>\n

item<\/strong> – an item (number, string, list, etc.) that will be appended to the end of the list<\/p>\n

Return Value:<\/strong><\/p>\n

The append() method produces no output (returns None).<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list = [\"hello\", \"this\", \"is\"]\r\nItem to be added = \"btechgeeks\"<\/pre>\n

Output:<\/strong><\/p>\n

The given list after appending { btechgeeks } =  ['hello', 'this', 'is', 'btechgeeks']<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given list = [10, 15, 20, 25]\r\nItem to be added = 30<\/pre>\n

Output:<\/strong><\/p>\n

The given list after appending { 30 } = [10, 15, 20, 25, 30]<\/pre>\n

List append() Method with Examples in Python<\/h2>\n