[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-0-en-105":3,"doc-seo-671624-105":59,"doc-detail-671624-en":130,"doc-similar-671624":148},{"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","python-cheat-sheet-complex-data-types","Python Cheat Sheet - Complex Data Types","","Concise cheat sheet covering Python’s complex data types and core operations. Explains list behavior (mutable sequences), element addition via append/insert/concatenation, and key mutation tasks like removal, reversing, and sorting with sorting complexity noted as O(n log n). Includes list indexing guidance, stack usage via append/pop, set semantics as unordered unique collections, and dictionary key-value storage with access patterns, membership checks, and iteration using items().",{"@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/python-cheat-sheet-complex-data-types/671624/",{"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/python-cheat-sheet-complex-data-types/671624.png","ImageObject",300,407,{"name":92,"@type":93},"Jasmine","Person",{"url":74,"name":95,"@type":96},"DocShare","Organization","application/pdf","2026-11-27","2026-11-02",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 I add elements to a Python list?","Question",{"text":112,"@type":113},"Use append() to add at the end, insert(pos, value) to add at a specific position, or concatenate lists with +.","Answer",{"name":115,"@type":110,"acceptedAnswer":116},"What is the difference between a list and a set in Python?",{"text":117,"@type":113},"A list is a mutable ordered sequence that can contain repeated elements, while a set is unordered and each element appears only once.",{"name":119,"@type":110,"acceptedAnswer":120},"How can I access and iterate over dictionary data?",{"text":121,"@type":113},"Access values by key using dictionary[key]. To iterate over all key-value pairs, use the items() method.","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},671624,1793577649,{"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":8,"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":81,"preview_page_count":8,"preview_urls":143},2336478487870,"https://ap-avatar.wpscdn.com/davatar_085a072bc5b1113ac321206ff7593b45","Python Cheat Sheet-Complex Data Types  \n“A puzzle a day to learn, code, and play” → Visit [finxter.com](finxter.com)  \n\n|  | Description | Example |\n| --- | --- | --- |\n| List | A container data type that stores a sequence of elements. Unlike strings, lists are mutable: modification possible. | l = [1 , 2 , 2]\u003Cbr>print(len(l)) \\# 3 |\n| Adding elements | Add elements to a list with (i) append, (ii) insert, or (iii) list concatenation.\u003Cbr>The append operation is very fast. | [1 , 2 , 2].append(4) \\# [1, 2, 2, 4]\u003Cbr>[1 , 2 , 4].insert(2 ,2) \\# [1, 2, 2, 4]\u003Cbr>[1 , 2 , 2] + [4] \\# [1, 2, 2, 4] |\n| Removal | Removing an element can be slower. | [1 , 2 , 2 , 4].remove(1) \\# [2, 2, 4] |\n| Reversing | This reverses the order of list elements. | [1 , 2 , 3].reverse() \\# [3, 2, 1] |\n| Sorting | Sorts a list. The computational complexity of sorting is O(n log n) for n list elements. | [2 , 4 , 2].sort() \\# [2, 2, 4] |\n| Indexing | Finds the first occurence of an element in the list & returns its index. Can be slow asthe whole list is traversed. | [2 , 2 , 4].index(2) \\# index of element 4 is \"0\"\u003Cbr>[2 , 2 , 4].index(2 ,1) \\# index of element 2 after pos 1 is \"1\" |\n| Stack | Python lists can be used intuitively as stack via the two list operations append() and pop() . | stack = [3]\u003Cbr>stack.append(42) \\# [3, 42]\u003Cbr>stack.pop() \\# 42 (stack: [3])\u003Cbr>stack.pop() \\# 3 (stack: []) |\n| Set | A set is an unordered collection of elements. Each can exist only once. | basket = { 'apple' , 'eggs' , 'banana' , 'orange'}\u003Cbr>same = set([ 'apple' , 'eggs' , 'banana' , 'orange']) |\n| Dictionary | The dictionary is a useful data structure for storing (key, value) pairs. | calories = { 'apple' : 52 , 'banana' : 89 , 'choco' : 546} |\n| Reading and writing elements | Read and write elements by specifying the key within the brackets. Use the keys() and values() functions to access all keys and values of the dictionary. | print(calories[ 'apple' ] \u003C calories[ 'choco']) \\# True calories[ 'cappu' ] = 74\u003Cbr>print(calories[ 'banana' ] \u003C calories[ 'cappu']) \\# False print( 'apple' in calories.keys()) \\# True\u003Cbr>print(52 in calories.values()) \\# True |\n| Dictionary Looping | You can loop over the (key, value) pairs of a dictionary with the items() method. | for k, v in calories.items():\u003Cbr>print(k) if v > 500 else None \\# 'chocolate' |\n| Membership operator | Check with the ‘in’ keyword whether theset, list, or dictionary contains an element. Set containment is faster than list containment. | basket = { 'apple' , 'eggs' , 'banana' , 'orange'}\u003Cbr>print( 'eggs' in basket} \\# True\u003Cbr>print( 'mushroom' in basket} \\# False |\n| List and Set\u003Cbr>Comprehension | List comprehension is the concise Python way to create lists. Use brackets plus an expression, followed by a for clause. Close with zero or more for or if clauses.\u003Cbr>Set comprehension is similar to list comprehension. | \\# List comprehension\u003Cbr>l = [( 'Hi ' + x) for x in [ 'Alice' , 'Bob' , 'Pete' ]] print(l) \\# ['Hi Alice', 'Hi Bob', 'Hi Pete']\u003Cbr>l2 = [x * y for x in range(3) for y in range(3) if x>y] print(l2) \\# [0, 0, 2]\u003Cbr>\\# Set comprehension\u003Cbr>squares = { x**2 for x in [0 ,2 ,4] if x \u003C 4 } \\# {0, 4} |","cbCaieQkIWxopmk2","https://ap.wps.com/l/cbCaieQkIWxopmk2","pdf",96667,"English","# List\n## Adding elements\n## Removal, reversing, sorting, indexing\n## Stack usage\n# Set\n# Dictionary\n## Reading and writing elements\n## Dictionary looping\n## Membership operator\n# Comprehension","[{\"question\":\"How do I add elements to a Python list?\",\"answer\":\"Use append() to add at the end, insert(pos, value) to add at a specific position, or concatenate lists with +.\"},{\"question\":\"What is the difference between a list and a set in Python?\",\"answer\":\"A list is a mutable ordered sequence that can contain repeated elements, while a set is unordered and each element appears only once.\"},{\"question\":\"How can I access and iterate over dictionary data?\",\"answer\":\"Access values by key using dictionary[key]. To iterate over all key-value pairs, use the items() method.\"}]","Python Cheat Sheet - Complex Data Types | PDF",[144],{"page_no":8,"url":145,"width":146,"height":147},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-18/4685cad2b4d0a9b7b626c889dbdeaa6f.webp",983,1272,{"list":149,"token":66},[150,156,162,168,174,180,186,191,197,203],{"doc_id":151,"doc_title":152,"file_type":137,"home_preview_img_url":153,"slug":154,"view_count":24,"category_name":30,"create_tm":155},670916,"cheat_sheet-python-final-medium - List Comprehension & Indexing","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229988704036/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=m1tOOsoRLkitO6m%2B%2BuDfVuLvz2o%3D","cheat_sheet-python-final-medium-list-comprehension-indexing",1793572695,{"doc_id":157,"doc_title":158,"file_type":137,"home_preview_img_url":159,"slug":160,"view_count":19,"category_name":30,"create_tm":161},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=1796111939&Signature=LgQJ7a4%2FQuoTQq8B80xdrDK7ZpI%3D","unit-iii-2-lists-tuples-dictionaries-41-lists-list-operations-and-methods",1794446558,{"doc_id":163,"doc_title":164,"file_type":137,"home_preview_img_url":165,"slug":166,"view_count":24,"category_name":30,"create_tm":167},685631,"Introduction to List - List Operations - Traversing a List - List Methods and Built-in Functions","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110229999084036/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=Oxd67DRRcLR82CIJf8%2BaMczjuig%3D","introduction-to-list-list-operations-traversing-a-list-list-methods-and-built-in-functions",1794016095,{"doc_id":169,"doc_title":170,"file_type":137,"home_preview_img_url":171,"slug":172,"view_count":34,"category_name":30,"create_tm":173},697976,"6.0001 Lecture 5 - Tuples, Lists, Aliasing, Mutability, Cloning","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230010146768/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111939&Signature=SENBcerOmy3WNGB90%2Bb9nOedtF8%3D","60001-lecture-5-tuples-lists-aliasing-mutability-cloning",1794446554,{"doc_id":175,"doc_title":176,"file_type":137,"home_preview_img_url":177,"slug":178,"view_count":29,"category_name":30,"create_tm":179},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=1796111939&Signature=BRhQ97HqjJNJPyZTRao9ZeXassc%3D","python-collections-arrays-list-and-function",1794016101,{"doc_id":181,"doc_title":182,"file_type":137,"home_preview_img_url":183,"slug":184,"view_count":81,"category_name":30,"create_tm":185},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=1796111939&Signature=Q567A6l9djmtSX4b6Q3vvmeUHFY%3D","lists-and-tuples-learn-to-create-and-use-1d-lists-tuples-and-2d-lists",1794018226,{"doc_id":187,"doc_title":188,"file_type":137,"home_preview_img_url":189,"slug":190,"view_count":81,"category_name":30,"create_tm":173},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=1796111939&Signature=OlYtJhHL%2BaOWK93Zp9ccEgxA84M%3D","python-variable-types-variable-assignment-multiple-assignment-and-standard-data-types",{"doc_id":192,"doc_title":193,"file_type":137,"home_preview_img_url":194,"slug":195,"view_count":19,"category_name":30,"create_tm":196},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=1796111939&Signature=IguPqX%2FBwXJsq0q%2Bqn4bNKjPeW4%3D","tuples-and-dictionaries-introduction-to-tuples",1794446564,{"doc_id":198,"doc_title":199,"file_type":137,"home_preview_img_url":200,"slug":201,"view_count":19,"category_name":30,"create_tm":202},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=1796111939&Signature=tKYfhzhdL%2B16WC0YPdT5z1v3GHM%3D","list-in-python-a-beginner-guide",1794016087,{"doc_id":204,"doc_title":205,"file_type":137,"home_preview_img_url":206,"slug":207,"view_count":34,"category_name":30,"create_tm":208},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=1796111939&Signature=jumpzko6zAQfaWcOKaCtvUrdyuY%3D","compound-data-lists-tuples-dictionaries-unit-iv-learning-notes",1794018217]