[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-670916-105":59,"doc-detail-670916-en":130,"doc-similar-670916":151},{"code":4,"msg":5,"data":6},0,"success",[7,13,18,23,28,33,38,43,48,51,55],{"id":8,"doc_module":4,"doc_module_name":9,"category_name":10,"show_sort_weight":11,"slug":12},1,"Document","Story & Novel",90,"story-novel",{"id":14,"doc_module":4,"doc_module_name":9,"category_name":15,"show_sort_weight":16,"slug":17},2,"Literature",80,"literature",{"id":19,"doc_module":4,"doc_module_name":9,"category_name":20,"show_sort_weight":21,"slug":22},4,"Exam",70,"exam",{"id":24,"doc_module":4,"doc_module_name":9,"category_name":25,"show_sort_weight":26,"slug":27},5,"Comic",60,"comic",{"id":29,"doc_module":4,"doc_module_name":9,"category_name":30,"show_sort_weight":31,"slug":32},6,"Technology",50,"technology",{"id":34,"doc_module":4,"doc_module_name":9,"category_name":35,"show_sort_weight":36,"slug":37},7,"Healthcare",40,"healthcare",{"id":39,"doc_module":4,"doc_module_name":9,"category_name":40,"show_sort_weight":41,"slug":42},8,"Research & Report",30,"research-report",{"id":44,"doc_module":4,"doc_module_name":9,"category_name":45,"show_sort_weight":46,"slug":47},9,"Religion & Spirituality",20,"religion-spirituality",{"id":46,"doc_module":4,"doc_module_name":9,"category_name":49,"show_sort_weight":46,"slug":50},"World Cup","world-cup",{"id":52,"doc_module":4,"doc_module_name":9,"category_name":53,"show_sort_weight":52,"slug":54},10,"Lifestyle","lifestyle",{"id":56,"doc_module":4,"doc_module_name":9,"category_name":57,"show_sort_weight":24,"slug":58},19,"General","general",{"code":4,"msg":60,"data":61},"ok",{"site_id":62,"language":63,"slug":64,"title":65,"keywords":66,"description":67,"schema_data":68,"social_meta":123,"head_meta":125,"extra_data":127,"updated_unix":129},105,"en","cheat_sheet-python-final-medium-list-comprehension-indexing","cheat_sheet-python-final-medium - List Comprehension & Indexing","","Python cheat sheet focused on list programming patterns, including creation, comprehension, indexing, slicing, length, membership tests, comparisons, and manipulation. Covers common operations such as concatenation, repetition, adding elements (append, extend, insert), removing elements (remove, pop), and deleting slices or indices with del. Includes utilities for counting, searching, reversing, and sorting, plus a final section on converting between strings and lists for quick data transformations.",{"@graph":69,"@context":122},[70,84,105],{"@type":71,"itemListElement":72},"BreadcrumbList",[73,77,79,82],{"item":74,"name":75,"@type":76,"position":8},"https://docshare.wps.com","Home","ListItem",{"item":78,"name":9,"@type":76,"position":14},"https://docshare.wps.com/document/",{"item":80,"name":30,"@type":76,"position":81},"https://docshare.wps.com/document/technology/",3,{"item":83,"name":65,"@type":76,"position":19},"https://docshare.wps.com/document/cheat_sheet-python-final-medium-list-comprehension-indexing/670916/",{"url":83,"name":65,"@type":85,"image":86,"author":91,"headline":65,"publisher":94,"fileFormat":97,"inLanguage":63,"description":67,"dateModified":98,"datePublished":99,"encodingFormat":97,"isAccessibleForFree":100,"interactionStatistic":101},"DigitalDocument",{"url":87,"@type":88,"width":89,"height":90},"https://docshare.wps.com/thumbnails/cheat_sheet-python-final-medium-list-comprehension-indexing/670916.png","ImageObject",300,407,{"name":92,"@type":93},"Adam","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-30","2026-11-01",true,{"@type":102,"interactionType":103,"userInteractionCount":24},"InteractionCounter",{"@type":104},"ViewAction",{"@type":106,"mainEntity":107},"FAQPage",[108,114,118],{"name":109,"@type":110,"acceptedAnswer":111},"How do you create an empty list and a list from a string in Python?","Question",{"text":112,"@type":113},"Use [] for an empty list and list(\"abc\") to convert a string into a list of characters.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What are common ways to access and extract parts of a list?",{"text":117,"@type":113},"Use indexing like l[0] or l[-1] for single elements, and slicing like l[1:3], l[:2], or l[::2] to get ranges.",{"name":119,"@type":110,"acceptedAnswer":120},"Which methods help you modify a list by adding or removing elements?",{"text":121,"@type":113},"Add with append(), extend(), and insert(); remove with remove() and pop(); delete items by index or slice using del l[i] or del l[a:b].","https://schema.org",{"og:url":83,"og:type":124,"og:title":65,"og:site_name":95,"og:description":67},"article",{"robots":126,"canonical":83},"index,follow",{"doc_id":128,"site_id":62},670916,1793572695,{"code":4,"msg":5,"data":131},{"doc_id":128,"user_id":132,"nickname":92,"user_avatar":133,"doc_module":4,"category_id":29,"category_name":30,"doc_title":65,"doc_description":67,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":24,"is_deleted":4,"is_public":8,"is_downloadable":8,"audit_status":8,"page_count":14,"language":139,"language_code":63,"site_id":62,"html_lang":63,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":67,"update_tm":129,"read_time":24,"preview_page_count":14,"preview_urls":143},1374404737137,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d","Python Cheat Sheet  \nFor Beginners & Lazy Experts (2/2)  \n\n| Lists |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| List Creation |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | l | = | []; l |  |  |  |  |  |  |  |  |  |  |  | [] |  |  >>> l = list(); |  |  |  |  |  |  | l | \u003Cbr>[] |\n| >>> | l | = | list(\"abc\"); |  |  |  |  |  |  |  |  | l |  |  |  |  | ['a', 'b', 'c'] |  |  |  |  |  |  |  |  |\n| List Comprehension |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> [x for x in range(10) if x % 2] [1, 3, 5, 7, 9] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> [c for c in \"ABCDE\" if c not in \"ACE\"] ['B', 'D'] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| List Indexing |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | [1, 2, 4][0] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | \u003Cbr>1 |  |  |  |  |  |  |  |  |\n| >>> | [1, 2, 4][-1] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | 4 |  |  |  |  |  |  |  |  |\n| >>> | [[1,2] |  |  |  | , | [3,4] |  | , | [5,6] |  |  |  | ] | [1] |  |  | \u003Cbr>[3,4] |  |  |  |  |  |  |  |  |\n| >>> | [[1,2] |  |  |  | , | [3,4] |  | , | [5,6] |  |  |  | ] | [1] |  | [1] | 4 |  |  |  |  |  |  |  |  |\n| List Slicing |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | [0, 1, 2, 3, 4][1:3] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | [1, 2] |  |  |  |\n| >>> | [0, 1, 2, 3, 4][:2] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | [0, 1] |  |  |  |\n| >>> | [0, 1, 2, 3, 4][::2] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | [0, 2, 4] |  |  |  |\n| >>> | l = [0, 1, 2, 3, 4]; x = slice(1, 4); l[x] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | [1, 2, 3] |  |  |  |\n| List Length |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> len([0,'a', 1]) 3 >>> len([]) 0 |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| List Membership |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> 0 in [0, 'a', 1] True >>> '0' in [0, 'a', 1] False |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| List Comparison |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | [0, 'a', 2] |  |  |  |  |  | == |  |  | [0, 'a', 2] |  |  |  |  |  |  | \u003Cbr>True |  |  |  |  |  |  |  |  |\n| >>> | [0, 'a', 2] |  |  |  |  |  | > |  |  | [0, 'b', 1] |  |  |  |  |  |  | False |  |  |  |  |  |  |  |  |\n| >>> | ['a', 1, 2] |  |  |  |  |  | > |  |  | ['a', 1] |  |  |  |  |  |  | \u003Cbr>True |  |  |  |  |  |  |  |  |\n| List Manipulation |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> l = [1, 2, 3] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> l[0] = '1'; |  |  |  |  |  |  | l |  |  |  | ['1', 2, 3] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| Concatenation |  |  |  |  |  |  | and |  |  |  | Repetition |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> l = [2] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | l | += |  | [3]; l |  |  | [2, 3] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | l | *= |  | 3; l |  |  | \u003Cbr>[2, 3, 2, 3, 2, 3] |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| Adding Elements |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |\n| >>> | l | = | [2, 3]; |  |  |  | l.append(1); l |  |  |  |  |  |  |  |  |  |  | [2, 3, 1 ] |  |  |  |  |  |  |  |\n| >>> | l | = | [2, 3]; |  |  |  | l.extend ('bc'); l |  |  |  |  |  |  |  |  |  |  | [2, 3, 'b', 'c'] |  |  |  |  |  |  |  |\n| >>> | l | = | [2, 3]; |  |  |  | ","cbCait133ytDRrTL","https://ap.wps.com/l/cbCait133ytDRrTL","pdf",64244,"English","# List Creation\n## List Comprehension\n## List Indexing and Slicing\n## List Utilities and Comparison\n## List Manipulation\n## Adding, Removing, Deleting Elements\n## Counting, Searching, and Sorting\n## String-to-List and Back","[{\"question\":\"How do you create an empty list and a list from a string in Python?\",\"answer\":\"Use [] for an empty list and list(\\\"abc\\\") to convert a string into a list of characters.\"},{\"question\":\"What are common ways to access and extract parts of a list?\",\"answer\":\"Use indexing like l[0] or l[-1] for single elements, and slicing like l[1:3], l[:2], or l[::2] to get ranges.\"},{\"question\":\"Which methods help you modify a list by adding or removing elements?\",\"answer\":\"Add with append(), extend(), and insert(); remove with remove() and pop(); delete items by index or slice using del l[i] or del l[a:b].\"}]","cheat_sheet-python-final-medium - List Comprehension & Indexing | PDF",[144,148],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/930f1ad8861712e741f49e03bd3e4090.webp",983,694,{"page_no":14,"url":149,"width":150,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/ee8dc8bf726e2625def0b35dfd22af49.webp",982,{"list":152,"token":66},[153,159,165,171,177,183,189,195,201,207],{"doc_id":154,"doc_title":155,"file_type":137,"home_preview_img_url":156,"slug":157,"view_count":24,"category_name":30,"create_tm":158},671624,"Python Cheat Sheet - Complex Data Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988737384/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=JHJ94uSRlNOQfkw0nr06H%2F3w03k%3D","python-cheat-sheet-complex-data-types",1793577649,{"doc_id":160,"doc_title":161,"file_type":137,"home_preview_img_url":162,"slug":163,"view_count":19,"category_name":30,"create_tm":164},697977,"UNIT-III-2 - Lists, Tuples, Dictionaries - 4.1 Lists - List Operations and Methods","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146775/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=5U4bKpm8yvXcwjCLebuC%2BNxYPwQ%3D","unit-iii-2-lists-tuples-dictionaries-41-lists-list-operations-and-methods",1794446558,{"doc_id":166,"doc_title":167,"file_type":137,"home_preview_img_url":168,"slug":169,"view_count":29,"category_name":30,"create_tm":170},685634,"Python Collections - Arrays - List and Function","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999084045/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=W6KIeLwh5ouCLW5TuOGi4N9PB8g%3D","python-collections-arrays-list-and-function",1794016101,{"doc_id":172,"doc_title":173,"file_type":137,"home_preview_img_url":174,"slug":175,"view_count":34,"category_name":30,"create_tm":176},685788,"Python Arrays - Learn How to Create, Access, and Modify Lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999694760/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=rs2oamYMpxB9v0LHyUCQfZcaXlM%3D","python-arrays-learn-how-to-create-access-and-modify-lists",1794018478,{"doc_id":178,"doc_title":179,"file_type":137,"home_preview_img_url":180,"slug":181,"view_count":81,"category_name":30,"create_tm":182},685777,"Lists and Tuples - Learn to create and use 1D lists, tuples and 2D lists","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203949/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=gc%2B2npMvn6v8Fxr%2BQTfzF11871A%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":184,"doc_title":185,"file_type":137,"home_preview_img_url":186,"slug":187,"view_count":24,"category_name":30,"create_tm":188},685635,"Lists, Tuples and Dictionaries - Lecture 10","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000169926/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=MljGTLfAf2%2BGPcEIuMws7J5yv%2F0%3D","lists-tuples-and-dictionaries-lecture-10",1794016103,{"doc_id":190,"doc_title":191,"file_type":137,"home_preview_img_url":192,"slug":193,"view_count":19,"category_name":30,"create_tm":194},685627,"List in Python - A Beginner Guide -","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000169755/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=Of4sKV%2Fu1g%2FGhW%2FTpdD3Z%2BXiBZ8%3D","list-in-python-a-beginner-guide",1794016087,{"doc_id":196,"doc_title":197,"file_type":137,"home_preview_img_url":198,"slug":199,"view_count":34,"category_name":30,"create_tm":200},685771,"Compound Data - Lists, Tuples, Dictionaries - Unit IV - Learning Notes","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203726/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=F7DLudLeL7w0ZXnUPDQvD7bq7Ok%3D","compound-data-lists-tuples-dictionaries-unit-iv-learning-notes",1794018217,{"doc_id":202,"doc_title":203,"file_type":137,"home_preview_img_url":204,"slug":205,"view_count":81,"category_name":30,"create_tm":206},697975,"Python Variable Types - Variable Assignment, Multiple Assignment, and Standard Data Types","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146715/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=%2BmcA6ERW4OuXSQFq4SbeMbNyzY4%3D","python-variable-types-variable-assignment-multiple-assignment-and-standard-data-types",1794446554,{"doc_id":208,"doc_title":209,"file_type":137,"home_preview_img_url":210,"slug":211,"view_count":19,"category_name":30,"create_tm":212},697980,"TUPLES AND DICTIONARIES - Introduction to Tuples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146829/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=ndtMg7VKuh%2FVZnGgkoFg2qKMT3g%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564]