{"id":3511,"date":"2023-10-22T15:04:20","date_gmt":"2023-10-22T09:34:20","guid":{"rendered":"https:\/\/python-programs.com\/?p=3511"},"modified":"2023-11-10T11:54:58","modified_gmt":"2023-11-10T06:24:58","slug":"python-programming-some-list-operations","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-programming-some-list-operations\/","title":{"rendered":"Python Programming \u2013 Some List Operations"},"content":{"rendered":"

In this Page, We are Providing Python Programming \u2013 Some List Operations. Students can visit for more Detail and Explanation of Python Handwritten Notes<\/a>\u00a0Pdf.<\/p>\n

Python Programming \u2013 Some List Operations<\/h2>\n

Some list operations<\/strong><\/p>\n

Some of the list operations supported by Python are given below.<\/p>\n

Concatenation<\/strong><\/p>\n

List concatenation can be carried out using the + operator.<\/p>\n

>>> [ 1 , 2 , 3 ] +[ ' hi ' , ' hello ' ]\r\n[ 1 , 2 , 3 , ' hi ' , ' hello ' ] ;<\/pre>\n

Repetition<\/strong><\/p>\n

The * operator can be used to carry out repetition operations.<\/p>\n

>>> [ ' Hey ' ] *3 \r\n[ ' Hey ' , ' Hey ' , ' Hey ' ]<\/pre>\n

Membership operation<\/strong><\/p>\n

The list also supports membership operation i.e. checking the existence of an element in a list.<\/p>\n

>>> 4 in [ 6 , 8 , 1 , 3 , 5 , 0 ]\r\nFalse \r\n>>> 1 in [ 6 , 8 , 1 , 3 , 5 , 0 ]\r\nTrue<\/pre>\n

Slicing operation<\/strong><\/p>\n

As list is a sequence, so indexing and slicing work the same way for list as they do for strings. All slice operations return a new list containing the requested elements:<\/p>\n

>>> a= [ ' spam ' , ' eggs ' , 100 , 1234 ]\r\n>>> a [ 2 ] \r\n100\r\n>>> a [ -2 ]\r\n100\r\n>>> a [ 1 : 3 ] \r\n[ ' eggs ' , 100 ]\r\n>>> a [ : ]\r\n[ ' spam ' , ' eggs ' , 100 , 1234 ]<\/pre>\n

List slicing can be in form of steps, the operation s [ i: j: k ] slices the list s from i to j with step k.<\/p>\n

>>> squares=[ x**2 for x in range ( 10 ) ] \r\n>>> squares\r\n[ 0 , 1 , 4 , 9 , 16 , 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 ]\r\n>>> squares [ 2 : 12 : 3 ]\r\n[ 4 , 25 , 64 , 121 ]<\/pre>\n

Slice indices have useful defaults, an omitted first index defaults to zero, an omitted second index defaults to the size of the list being sliced.<\/p>\n

>>> squares= [ x**2 for x in range ( 10 ) ]\r\n>>> squares \r\n[0 , 1 , 4 , 9 , 16 , 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 ]\r\n>>> squares [ 5 : ]\r\n[ 25 , 36 , 49 , 64 , 81 , 100 , 121 , 144 , 169 , 196 ]\r\n>>> squares [ : 5 ]\r\n[ 0 , 1 , 4 , 9 , 16 ]<\/pre>\n","protected":false},"excerpt":{"rendered":"

In this Page, We are Providing Python Programming \u2013 Some List Operations. Students can visit for more Detail and Explanation of Python Handwritten Notes\u00a0Pdf. Python Programming \u2013 Some List Operations Some list operations Some of the list operations supported by Python are given below. Concatenation List concatenation can be carried out using the + operator. …<\/p>\n

Python Programming \u2013 Some List Operations<\/span> Read More »<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[5],"tags":[],"yoast_head":"\nPython Programming \u2013 Some List Operations - Python Programs<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/python-programs.com\/python-programming-some-list-operations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Programming \u2013 Some List Operations - Python Programs\" \/>\n<meta property=\"og:description\" content=\"In this Page, We are Providing Python Programming \u2013 Some List Operations. Students can visit for more Detail and Explanation of Python Handwritten Notes\u00a0Pdf. Python Programming \u2013 Some List Operations Some list operations Some of the list operations supported by Python are given below. Concatenation List concatenation can be carried out using the + operator. … Python Programming \u2013 Some List Operations Read More »\" \/>\n<meta property=\"og:url\" content=\"https:\/\/python-programs.com\/python-programming-some-list-operations\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Programs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/btechgeeks\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-22T09:34:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-11-10T06:24:58+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@btech_geeks\" \/>\n<meta name=\"twitter:site\" content=\"@btech_geeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prasanna\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/python-programs.com\/#organization\",\"name\":\"BTech Geeks\",\"url\":\"https:\/\/python-programs.com\/\",\"sameAs\":[\"https:\/\/www.instagram.com\/btechgeeks\/\",\"https:\/\/www.linkedin.com\/in\/btechgeeks\",\"https:\/\/in.pinterest.com\/btechgeek\/\",\"https:\/\/www.youtube.com\/channel\/UC9MlCqdJ3lKqz2p5114SDIg\",\"https:\/\/www.facebook.com\/btechgeeks\",\"https:\/\/twitter.com\/btech_geeks\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/python-programs.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png\",\"contentUrl\":\"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png\",\"width\":350,\"height\":70,\"caption\":\"BTech Geeks\"},\"image\":{\"@id\":\"https:\/\/python-programs.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/python-programs.com\/#website\",\"url\":\"https:\/\/python-programs.com\/\",\"name\":\"Python Programs\",\"description\":\"Python Programs with Examples, How To Guides on Python\",\"publisher\":{\"@id\":\"https:\/\/python-programs.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/python-programs.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#webpage\",\"url\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/\",\"name\":\"Python Programming \u2013 Some List Operations - Python Programs\",\"isPartOf\":{\"@id\":\"https:\/\/python-programs.com\/#website\"},\"datePublished\":\"2023-10-22T09:34:20+00:00\",\"dateModified\":\"2023-11-10T06:24:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/python-programs.com\/python-programming-some-list-operations\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/python-programs.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Programming \u2013 Some List Operations\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#webpage\"},\"author\":{\"@id\":\"https:\/\/python-programs.com\/#\/schema\/person\/ea8ce699662f0d7e248e52fe080b85bb\"},\"headline\":\"Python Programming \u2013 Some List Operations\",\"datePublished\":\"2023-10-22T09:34:20+00:00\",\"dateModified\":\"2023-11-10T06:24:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#webpage\"},\"wordCount\":171,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/python-programs.com\/#organization\"},\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/python-programs.com\/python-programming-some-list-operations\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/python-programs.com\/#\/schema\/person\/ea8ce699662f0d7e248e52fe080b85bb\",\"name\":\"Prasanna\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/python-programs.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/174540ad43736c7d1a4c4f83c775e74d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/174540ad43736c7d1a4c4f83c775e74d?s=96&d=mm&r=g\",\"caption\":\"Prasanna\"},\"url\":\"https:\/\/python-programs.com\/author\/prasanna\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Programming \u2013 Some List Operations - Python Programs","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/python-programs.com\/python-programming-some-list-operations\/","og_locale":"en_US","og_type":"article","og_title":"Python Programming \u2013 Some List Operations - Python Programs","og_description":"In this Page, We are Providing Python Programming \u2013 Some List Operations. Students can visit for more Detail and Explanation of Python Handwritten Notes\u00a0Pdf. Python Programming \u2013 Some List Operations Some list operations Some of the list operations supported by Python are given below. Concatenation List concatenation can be carried out using the + operator. … Python Programming \u2013 Some List Operations Read More »","og_url":"https:\/\/python-programs.com\/python-programming-some-list-operations\/","og_site_name":"Python Programs","article_publisher":"https:\/\/www.facebook.com\/btechgeeks","article_published_time":"2023-10-22T09:34:20+00:00","article_modified_time":"2023-11-10T06:24:58+00:00","twitter_card":"summary_large_image","twitter_creator":"@btech_geeks","twitter_site":"@btech_geeks","twitter_misc":{"Written by":"Prasanna","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/python-programs.com\/#organization","name":"BTech Geeks","url":"https:\/\/python-programs.com\/","sameAs":["https:\/\/www.instagram.com\/btechgeeks\/","https:\/\/www.linkedin.com\/in\/btechgeeks","https:\/\/in.pinterest.com\/btechgeek\/","https:\/\/www.youtube.com\/channel\/UC9MlCqdJ3lKqz2p5114SDIg","https:\/\/www.facebook.com\/btechgeeks","https:\/\/twitter.com\/btech_geeks"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/python-programs.com\/#\/schema\/logo\/image\/","url":"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png","contentUrl":"https:\/\/python-programs.com\/wp-content\/uploads\/2020\/11\/BTechGeeks.png","width":350,"height":70,"caption":"BTech Geeks"},"image":{"@id":"https:\/\/python-programs.com\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/python-programs.com\/#website","url":"https:\/\/python-programs.com\/","name":"Python Programs","description":"Python Programs with Examples, How To Guides on Python","publisher":{"@id":"https:\/\/python-programs.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/python-programs.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/python-programs.com\/python-programming-some-list-operations\/#webpage","url":"https:\/\/python-programs.com\/python-programming-some-list-operations\/","name":"Python Programming \u2013 Some List Operations - Python Programs","isPartOf":{"@id":"https:\/\/python-programs.com\/#website"},"datePublished":"2023-10-22T09:34:20+00:00","dateModified":"2023-11-10T06:24:58+00:00","breadcrumb":{"@id":"https:\/\/python-programs.com\/python-programming-some-list-operations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/python-programs.com\/python-programming-some-list-operations\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/python-programs.com\/python-programming-some-list-operations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/python-programs.com\/"},{"@type":"ListItem","position":2,"name":"Python Programming \u2013 Some List Operations"}]},{"@type":"Article","@id":"https:\/\/python-programs.com\/python-programming-some-list-operations\/#article","isPartOf":{"@id":"https:\/\/python-programs.com\/python-programming-some-list-operations\/#webpage"},"author":{"@id":"https:\/\/python-programs.com\/#\/schema\/person\/ea8ce699662f0d7e248e52fe080b85bb"},"headline":"Python Programming \u2013 Some List Operations","datePublished":"2023-10-22T09:34:20+00:00","dateModified":"2023-11-10T06:24:58+00:00","mainEntityOfPage":{"@id":"https:\/\/python-programs.com\/python-programming-some-list-operations\/#webpage"},"wordCount":171,"commentCount":0,"publisher":{"@id":"https:\/\/python-programs.com\/#organization"},"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/python-programs.com\/python-programming-some-list-operations\/#respond"]}]},{"@type":"Person","@id":"https:\/\/python-programs.com\/#\/schema\/person\/ea8ce699662f0d7e248e52fe080b85bb","name":"Prasanna","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/python-programs.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/174540ad43736c7d1a4c4f83c775e74d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/174540ad43736c7d1a4c4f83c775e74d?s=96&d=mm&r=g","caption":"Prasanna"},"url":"https:\/\/python-programs.com\/author\/prasanna\/"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts\/3511"}],"collection":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/comments?post=3511"}],"version-history":[{"count":1,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts\/3511\/revisions"}],"predecessor-version":[{"id":3513,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/posts\/3511\/revisions\/3513"}],"wp:attachment":[{"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/media?parent=3511"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/categories?post=3511"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/python-programs.com\/wp-json\/wp\/v2\/tags?post=3511"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}