{"id":3246,"date":"2022-11-13T20:55:54","date_gmt":"2022-11-13T20:55:54","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=3246"},"modified":"2022-11-13T20:55:57","modified_gmt":"2022-11-13T20:55:57","slug":"python-list-append","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/python-list-append\/","title":{"rendered":"Python list append"},"content":{"rendered":"<p style=\"text-align: center;\">Python List Append Method<\/p>\n<p>The append method helps us append some element to the list. By append, we mean that we are adding the element to the end of the list. Let\u2019s have a look at a simple program, which demonstrates about using the append method in our program.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3251 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON.jpg\" alt=\"\" width=\"915\" height=\"127\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON.jpg 915w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON-300x42.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON-768x107.jpg 768w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/p>\n<p>As you can see in the above program, we have the list, which has the names of some fruit\u2019s. Now, Let\u2019s say that we want to append another name of fruit into the list, we can simply do it using the append method. You can see in the example, that how are we using the append method on the list. With the append method, we have to pass what we want to append. It can be some item, like some number, or some string, or some list, etc., what you want to add to the end of the list.<\/p>\n<h2 style=\"text-align: center;\">Python List Append Method<\/h2>\n<p>So, with the append method, we are adding some item to the end of the list. Note that this method does not return anything.<\/p>\n<p>Let\u2019s also have a look at another program, which demonstrates adding another list to a list.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3252 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON-1.jpg\" alt=\"\" width=\"963\" height=\"138\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON-1.jpg 963w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON-1-300x43.jpg 300w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-append-METHOD-IN-PYTHON-1-768x110.jpg 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/p>\n<p>As you can see in the above program, we have a list of names of fruit\u2019s, and then we also have a list of some more names of fruit\u2019s, and we are trying to append a list, to another list. Let\u2019s have a look at the output now &#8211;<\/p>\n<p>[&#8216;Apple&#8217;, &#8216;Kiwi&#8217;, &#8216;Guava&#8217;, [&#8216;Strawberry&#8217;, &#8216;Orange&#8217;, &#8216;Tamarind&#8217;]]<\/p>\n<p>You can see in the output, that the list more_fruit\u2019s is added to the list fruit\u2019s, as a single item. So, we can make use of the append method as and when required, in our python programs. Note that this method as well, returns None.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python List Append Method The append method helps us append some element to the list. By append, we mean that we are adding the element to the end of the list. Let\u2019s have a look at a simple program, which demonstrates about using the append method in our program. As you can see in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[26,27],"class_list":{"0":"post-3246","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python-tutorial","7":"tag-python","8":"tag-python-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=3246"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3246\/revisions"}],"predecessor-version":[{"id":4065,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3246\/revisions\/4065"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=3246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=3246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=3246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}