[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-685634-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-685634-en":130,"doc-similar-685634":149},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","python-collections-arrays-list-and-function","Python Collections - Arrays - List and Function","","Python collections introduction focused on array data types and list operations. Explains the four built-in collection types—list, tuple, set, and dictionary—highlighting ordering, mutability, indexing, and duplicate rules. Provides practical list syntax and core techniques: item access by index including negative indexing, slicing ranges, updating elements, looping with for, membership checks with in, measuring length via len(), and common modification methods such as append, insert, remove, pop, clear, and del.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/technology/","Technology",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/python-collections-arrays-list-and-function/685634/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/python-collections-arrays-list-and-function/685634.png","ImageObject",300,407,{"name":42,"@type":43},"Ben ","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-24","2026-11-07",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",6,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What are the four Python collection data types and how do they differ?","Question",{"text":63,"@type":64},"Python provides list, tuple, set, and dictionary. Lists are ordered and changeable, tuples are ordered and unchangeable, sets are unordered and unindexed, and dictionaries are unordered, changeable, and indexed with key-based access.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How do you access list items and perform slicing in Python?",{"text":68,"@type":64},"List items are accessed using index numbers. Slicing uses a start and end index range, supports negative indexing from the end, and returns a new list of the specified items.",{"name":70,"@type":61,"acceptedAnswer":71},"Which methods can you use to add or remove items from a list?",{"text":72,"@type":64},"Use append() to add to the end, insert() to add at a specific index, and extend() to add elements from another list. To remove items, use remove() for a value, pop() for an index (or last item by default), clear() to empty the list, or del to delete by index or delete the list entirely.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},685634,1794016101,{"code":4,"msg":82,"data":83},"success",[84,88,92,96,101,104,109,114,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":97,"doc_module":4,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},5,"Comic",60,"comic",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":102,"slug":103},50,"technology",{"id":105,"doc_module":4,"doc_module_name":25,"category_name":106,"show_sort_weight":107,"slug":108},7,"Healthcare",40,"healthcare",{"id":110,"doc_module":4,"doc_module_name":25,"category_name":111,"show_sort_weight":112,"slug":113},8,"Research & Report",30,"research-report",{"id":115,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},9,"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":97,"slug":129},19,"General","general",{"code":4,"msg":82,"data":131},{"doc_id":79,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":55,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":55,"language":139,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":140,"faqs":141,"seo_title":142,"seo_description":12,"update_tm":80,"read_time":143,"preview_page_count":22,"preview_urls":144},2336478951081,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","Python Tutorial (list and function)  \nAdopted from: [https://www.w3schools.com/python/default.asp](https://www.w3schools.com/python/default.asp)  \nPython Collections (Arrays)  \nThere are four collection data types in the Python programming language:  \n• List is a collection which is ordered and changeable. Allows duplicate members.  \n• Tuple is a collection which is ordered and unchangeable. Allows duplicate members.  \n• Set is a collection which is unordered and unindexed. No duplicate members.  \n• Dictionary is a collection which is unordered, changeable and indexed. No duplicate members.  \nWhen choosing a collection type, it is useful to understand the properties of that type. Choosing the right type for a particular data set could mean retention of meaning, and, it could mean an increase inefficiency or security.  \nList  \nA list is a collection which is ordered and changeable. In Python lists are written with square brackets.  \nCreate a List:  \nthislist = [ \"apple\", \"banana\", \"cherry\"] print(thislist)  \nAccess Items  \nYou access the list items by referring to the index number  \nPrint the second item of the list:  \nthislist = [ \"apple\", \"banana\", \"cherry\"] print(thislist[1])  \nNegative Indexing  \nNegative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second last item etc.  \nthislist = [ \"apple\", \"banana\", \"cherry\"] print(thislist[-1])  \nRange of Indexes  \nYou can specify a range of indexes by specifying where to start and where to end the range.  \nWhen specifying a range, the return value will be anew list with the specified items.  \nReturn the third, fourth, and fifth item:  \nthislist = [ \"apple\", \"banana\", \"cherry\", \"orange\",\"kiwi\", \"melon\", \"mango\"] print(thislist[2:5])  \nThe search will start at index 2 (included) and end at index 5 (not included) .  \nBy leaving out the start value, the range will start atthe first item:  \nThis example returns the items from the beginning to\"orange\":  \nthislist = [ \"apple\", \"banana\", \"cherry\", \"orange\",\"kiwi\", \"melon\", \"mango\"]  \nprint(thislist[:4])  \nBy leaving out the end value, the range will go on to the end of the list:  \nThis example returns the items from \"cherry\" and to the end:  \nthislist = [ \"apple\", \"banana\", \"cherry\", \"orange\",\"kiwi\", \"melon\", \"mango\"]  \nprint(thislist[2:])  \nChange Item Value  \nTo change the value of a specific item, refer to the index number:  \nChange the second item:  \nthislist = [ \"apple\", \"banana\", \"cherry\"] thislist[1] = \"blackcurrant\"  \nprint(thislist)  \nLoop Through a List  \nYou can loop through the list items by using a for loop:  \nPrint all items in the list, one by one:  \nthislist = [ \"apple\", \"banana\", \"cherry\"]  \nfor x in thislist: print(x)  \nCheck if Item Exists  \nTo determine if a specified item is present in a list use the in keyword:  \nCheck if \"apple\" is present in the list: thislist = [ \"apple\", \"banana\", \"cherry\"] if \"apple\" in thislist:  \nprint(\"Yes, 'apple' is in the fruits list\")  \nList Length  \nTo determine how many items a list has, use thelen() function:  \nPrint the number of items in the list: thislist = [ \"apple\", \"banana\", \"cherry\"] print(len(thislist))  \nAdd Items  \nTo add an item to the end of the list, use the append() method:  \nUsing the append() method to append an item:  \nthislist = [ \"apple\", \"banana\", \"cherry\"] thislist.append(\"orange\")  \nprint(thislist)  \nTo add an item at the specified index, use the insert() method:  \nInsert an item as the second position:  \nthislist = [ \"apple\", \"banana\", \"cherry\"] thislist.insert(1, \"orange\")  \nprint(thislist)  \nRemove Item  \nThere are several methods to remove items from a list: The remove() method removes the specified item:  \nthislist = [ \"apple\", \"banana\", \"cherry\"] thislist.remove(\"banana\")  \nprint(thislist)  \nThe pop() method removes the specified index,(orthe last item if index is not specified):  \nthislist = [ \"apple\", \"banana\", \"cherry\"] thislist.pop()  \nprint(thislist)  \nThe clear() method empties the list:  \nthislist = [ \"apple\", \"bana","cbCaioLIw9xdPide","https://ap.wps.com/l/cbCaioLIw9xdPide","pdf",96424,"English","# Python Collections (Arrays)\n## Four collection data types\n## Lists: creation and access\n## Range indexing and slicing\n## Modifying list items\n## Looping, membership, and length\n## Adding and removing items\n## Copying and joining lists\n## List methods","[{\"question\":\"What are the four Python collection data types and how do they differ?\",\"answer\":\"Python provides list, tuple, set, and dictionary. Lists are ordered and changeable, tuples are ordered and unchangeable, sets are unordered and unindexed, and dictionaries are unordered, changeable, and indexed with key-based access.\"},{\"question\":\"How do you access list items and perform slicing in Python?\",\"answer\":\"List items are accessed using index numbers. Slicing uses a start and end index range, supports negative indexing from the end, and returns a new list of the specified items.\"},{\"question\":\"Which methods can you use to add or remove items from a list?\",\"answer\":\"Use append() to add to the end, insert() to add at a specific index, and extend() to add elements from another list. To remove items, use remove() for a value, pop() for an index (or last item by default), clear() to empty the list, or del to delete by index or delete the list entirely.\"}]","Python Collections - Arrays - List and Function | PDF",15,[145],{"page_no":22,"url":146,"width":147,"height":148},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-09/64ffa8f2c43c43d3a56f63b81d0ac876.webp",983,1272,{"list":150,"token":11},[151,157,163,169,175,181,187,193,198,204],{"doc_id":152,"doc_title":153,"file_type":137,"home_preview_img_url":154,"slug":155,"view_count":105,"category_name":29,"create_tm":156},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":158,"doc_title":159,"file_type":137,"home_preview_img_url":160,"slug":161,"view_count":105,"category_name":29,"create_tm":162},685773,"Lists and Tuples - Chapter 7 - Programming Concepts","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203784/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=kx6s1pNU36hyyYlAEUNFYt5aGXc%3D","lists-and-tuples-chapter-7-programming-concepts",1794018219,{"doc_id":164,"doc_title":165,"file_type":137,"home_preview_img_url":166,"slug":167,"view_count":33,"category_name":29,"create_tm":168},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":170,"doc_title":171,"file_type":137,"home_preview_img_url":172,"slug":173,"view_count":97,"category_name":29,"create_tm":174},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=1796111999&Signature=3zUMhSnQ6eajji96nyL5FcJra7o%3D","cheat_sheet-python-final-medium-list-comprehension-indexing",1793572695,{"doc_id":176,"doc_title":177,"file_type":137,"home_preview_img_url":178,"slug":179,"view_count":97,"category_name":29,"create_tm":180},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":182,"doc_title":183,"file_type":137,"home_preview_img_url":184,"slug":185,"view_count":33,"category_name":29,"create_tm":186},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,{"doc_id":188,"doc_title":189,"file_type":137,"home_preview_img_url":190,"slug":191,"view_count":30,"category_name":29,"create_tm":192},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":194,"doc_title":195,"file_type":137,"home_preview_img_url":196,"slug":197,"view_count":30,"category_name":29,"create_tm":162},685772,"UNIT-IV - LIST, TUPLES, DICTIONARIES - Problem Solving and Python Programming","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203776/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=feqBrhzgjP%2FJCYUkxcuWW00ckxM%3D","unit-iv-list-tuples-dictionaries-problem-solving-and-python-programming",{"doc_id":199,"doc_title":200,"file_type":137,"home_preview_img_url":201,"slug":202,"view_count":97,"category_name":29,"create_tm":203},685778,"1-Tuples","https://weboffice-temporary-prod-sg.obs.ap-southeast-3.myhuaweicloud.com:443/export/thumbnail/export/thumbnail/110230000203953/last/300/407?AWSAccessKeyId=HPUAE6OPDRI9QZXR6WJG&Expires=1796111999&Signature=D3wxv0cFXXA2AOvXbuAWe7DbHJg%3D","1-tuples",1794018230,{"doc_id":205,"doc_title":206,"file_type":137,"home_preview_img_url":207,"slug":208,"view_count":97,"category_name":29,"create_tm":209},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]