{"id":2640,"date":"2019-07-17T10:09:48","date_gmt":"2019-07-17T10:09:48","guid":{"rendered":"https:\/\/prwatech.in\/blog\/?p=2640"},"modified":"2024-03-26T06:55:25","modified_gmt":"2024-03-26T06:55:25","slug":"python-list-tutorial","status":"publish","type":"post","link":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/","title":{"rendered":"Python List Tutorial"},"content":{"rendered":"<p>&nbsp;<\/p>\n<h1>Python List Tutorial with Examples<\/h1>\n<p>&nbsp;<\/p>\n<p><strong>Python List Tutorial with Examples<\/strong>, In this tutorial, we will learn how to create a list in Python to your code and why it is important. Here, You will also learn various types of list methods in Python which are helpful for any <a href=\"https:\/\/prwatech.in\/python-training-institute-in-bangalore\/\">Python developers<\/a>. Are you looking for the Python list tutorial with examples or Are you dreaming to become to certified Pro Python Developer, then stop just dreaming, get your <a title=\"Python Certification Course in Bangalore\" href=\"https:\/\/prwatech.in\/python-certification-course-in-bangalore\/\">Python certification course<\/a> from India\u2019s Leading <a title=\"python training in btm Layout\" href=\"https:\/\/prwatech.in\/python-training-institute-in-btm-layout\/\">Python training institute<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>Lists in Python referred to as a sequence that is an ordered collection of objects which can host all objects of any data type in Python. Lists are one of the most useful and versatile Python Data Types. Do you want to know types of list methods in Python and how to create a list in Python, then just follow the below mentioned Python list tutorial for Beginners from <a href=\"https:\/\/prwatech.com\/\">Prwatech<\/a> and take advanced <a title=\"Python Certification Course in Bangalore\" href=\"https:\/\/prwatech.in\/python-training-institute-in-bangalore\/\">Python training<\/a> like a Pro from today itself under 10+ years of hands-on experienced Professionals.<\/p>\n<p>&nbsp;<\/p>\n<h2>What is Python List?<\/h2>\n<p>&nbsp;<\/p>\n<p>List in python is ordered collection which is mutable in nature. In Python list is enclosed with square brackets where elements are separated using a delimiter \u2018,\u2019 (comma).<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [11,22,33,44]<\/p>\n<p>L2= [\u201ca\u201d, \u201caa\u201d, \u201cabb\u201d]<\/p>\n<p>&nbsp;<\/p>\n<h2>How to create a list in Python?<\/h2>\n<p>&nbsp;<\/p>\n<p>List elements can be referred to using the index numbers where indexing starts from 0.<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [11,22,33,44]<\/p>\n<p>print(L1[2])<\/p>\n<p>To change the value of a specific element, refer to its index number:<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [11,22,33,44]<\/p>\n<p><strong>L1[2]<\/strong> = 55<\/p>\n<p>print(L1)<\/p>\n<p>You can loop through list elements by using a for loop:<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [11,22,33,44]<\/p>\n<p><strong>for<\/strong> x in L1:<\/p>\n<p>print(L1)<\/p>\n<p>To determine if a specific element is present in a list use keyword \u2018in\u2019.<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>if \u201caa\u201d <strong>in<\/strong> L1<\/p>\n<p>print(L1)<\/p>\n<p>To determine the number of elements in a list, use the method <strong>len()<\/strong>.<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>print(<strong>len(L1)<\/strong>)<strong>\u00a0<\/strong><\/p>\n<h2><strong>List <\/strong><strong>Methods in Python<\/strong><\/h2>\n<p>&nbsp;<\/p>\n<h3><strong>append():<\/strong> Used to add an element at the end of the list.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>L1.<strong>append(\u201chg\u201d)<\/strong><\/p>\n<p>print(L1)<\/p>\n<p>gives you: \u00a0[\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d, [\u201chg\u201d]]<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>insert(): <\/strong>Used to add an element at any specific position.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>L1.<strong>insert(3, \u201chg\u201d)<\/strong><\/p>\n<p>print(L1)<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>remove(): <\/strong>Used to remove an <strong>specific element<\/strong> from the list.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>L1.<strong>remove(\u201cab\u201d)<\/strong><\/p>\n<p>print(L1)<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>pop():<\/strong> Used to an element from <strong>specific index<\/strong> in a List.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>L1.<strong>pop(2)<\/strong><\/p>\n<p>print(L1)<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>del():<\/strong> It is used to delete a List completely.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>del L1<\/p>\n<p>&nbsp;<\/p>\n<h3>clear(): It is used to clear all elements from the list.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p><strong>L1.clear() <\/strong><\/p>\n<p>print(L1)<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>copy(): <\/strong>It is used to copy the elements from one List to another.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>L2=L1.<strong>copy()<\/strong><\/p>\n<p>print(L2)<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>extend():\u00a0<\/strong>Extends list by appending elements from the iterable.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>L1.<strong>extend(\u201cqw\u201d)<\/strong><\/p>\n<p>print(L1)<\/p>\n<p>gives you: [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d, \u201cqw\u201d]<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>index(): <\/strong>Returns index of a specific element.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>print(index(\u201ca\u201d))<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>reverse():<\/strong> It returns the reverse of a given list.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>print(reverse(L1))<\/p>\n<p>&nbsp;<\/p>\n<h3><strong>sort(): <\/strong>It returns sorted elements in a List.<\/h3>\n<p>&nbsp;<\/p>\n<p>Ex)\u00a0\u00a0\u00a0 L1= [\u201ca\u201d, \u201cab\u201d, \u201caaa\u201d, \u201ccc\u201d]<\/p>\n<p>print(<strong>sort(L1)<\/strong>)<\/p>\n<p>&nbsp;<\/p>\n<p>We hope you understand the Python list tutorial with examples and how to create a list in the <a href=\"https:\/\/prwatech.in\/python-training-institute-in-bangalore\/\">Python<\/a> concept. Get success in your career as a Python developer by being a part of the <a href=\"https:\/\/prwatech.com\/\">Prwatech<\/a>, India&#8217;s leading <a href=\"https:\/\/prwatech.in\/python-training-institute-in-bangalore\/\">Python training institute in Bangalore<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/WFk99tG29ag\" width=\"650\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Python List Tutorial with Examples &nbsp; Python List Tutorial with Examples, In this tutorial, we will learn how to create a list in Python to your code and why it is important. Here, You will also learn various types of list methods in Python which are helpful for any Python developers. Are you looking [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,1671],"tags":[1765,354,355,1767,1766],"class_list":["post-2640","post","type-post","status-publish","format-standard","hentry","category-python","category-python-data-types","tag-modifying-python-lists","tag-python-list-tutorial","tag-python-list-tutorial-with-examples","tag-python-sets","tag-understanding-sets-in-python-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python List Tutorial with Examples | How to create list in Python<\/title>\n<meta name=\"description\" content=\"Explore Python List tutorial with examples from Prwatech and Get to know how to create a list in Python &amp; different types of list methods.\" \/>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python List Tutorial with Examples | How to create list in Python\" \/>\n<meta property=\"og:description\" content=\"Explore Python List tutorial with examples from Prwatech and Get to know how to create a list in Python &amp; different types of list methods.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Prwatech\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prwatech.in\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-07-17T10:09:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-26T06:55:25+00:00\" \/>\n<meta name=\"author\" content=\"Prwatech\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:site\" content=\"@Eduprwatech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prwatech\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/\",\"url\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/\",\"name\":\"Python List Tutorial with Examples | How to create list in Python\",\"isPartOf\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#website\"},\"datePublished\":\"2019-07-17T10:09:48+00:00\",\"dateModified\":\"2024-03-26T06:55:25+00:00\",\"author\":{\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\"},\"description\":\"Explore Python List tutorial with examples from Prwatech and Get to know how to create a list in Python & different types of list methods.\",\"breadcrumb\":{\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/prwatech.in\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python List Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/prwatech.in\/blog\/#website\",\"url\":\"https:\/\/prwatech.in\/blog\/\",\"name\":\"Prwatech\",\"description\":\"Share Ideas, Start Something Good.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/prwatech.in\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3\",\"name\":\"Prwatech\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g\",\"caption\":\"Prwatech\"},\"url\":\"https:\/\/prwatech.in\/blog\/author\/prwatech123\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python List Tutorial with Examples | How to create list in Python","description":"Explore Python List tutorial with examples from Prwatech and Get to know how to create a list in Python & different types of list methods.","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Python List Tutorial with Examples | How to create list in Python","og_description":"Explore Python List tutorial with examples from Prwatech and Get to know how to create a list in Python & different types of list methods.","og_url":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/","og_site_name":"Prwatech","article_publisher":"https:\/\/www.facebook.com\/prwatech.in\/","article_published_time":"2019-07-17T10:09:48+00:00","article_modified_time":"2024-03-26T06:55:25+00:00","author":"Prwatech","twitter_card":"summary_large_image","twitter_creator":"@Eduprwatech","twitter_site":"@Eduprwatech","twitter_misc":{"Written by":"Prwatech","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/","url":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/","name":"Python List Tutorial with Examples | How to create list in Python","isPartOf":{"@id":"https:\/\/prwatech.in\/blog\/#website"},"datePublished":"2019-07-17T10:09:48+00:00","dateModified":"2024-03-26T06:55:25+00:00","author":{"@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3"},"description":"Explore Python List tutorial with examples from Prwatech and Get to know how to create a list in Python & different types of list methods.","breadcrumb":{"@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/prwatech.in\/blog\/python\/python-data-types\/python-list-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/prwatech.in\/blog\/"},{"@type":"ListItem","position":2,"name":"Python List Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/prwatech.in\/blog\/#website","url":"https:\/\/prwatech.in\/blog\/","name":"Prwatech","description":"Share Ideas, Start Something Good.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/prwatech.in\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/db90baff7744090b2288bbc98fea87f3","name":"Prwatech","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prwatech.in\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c00bafc1b04045f31eda917de39891456c44fa47c092b9bb6be0f860a3a30a2f?s=96&d=mm&r=g","caption":"Prwatech"},"url":"https:\/\/prwatech.in\/blog\/author\/prwatech123\/"}]}},"_links":{"self":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/comments?post=2640"}],"version-history":[{"count":12,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2640\/revisions"}],"predecessor-version":[{"id":10116,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/posts\/2640\/revisions\/10116"}],"wp:attachment":[{"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/media?parent=2640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/categories?post=2640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prwatech.in\/blog\/wp-json\/wp\/v2\/tags?post=2640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}