[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-573602-105":3,"detail-sidebar-cat-1-en-105":83,"doc-detail-573602-en":129},{"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":76,"head_meta":78,"extra_data":80,"updated_unix":82},105,"en","dictionaries-cheat-sheet-quick-python-dictionary-reference","Dictionaries Cheat Sheet - Quick Python Dictionary Reference","","A concise cheat sheet summarizing core operations and concepts for Python dictionaries. It defines dictionaries as key-value containers and explains syntax using curly braces, item access and update, deletion, and iteration. Key lookup behavior is covered, including returning values or raising KeyError, plus how membership tests work. It also lists utility methods for size and key/value retrieval: len(), max(), min(), keys(), values(), and items().",{"@graph":14,"@context":75},[15,34,54],{"@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/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/dictionaries-cheat-sheet-quick-python-dictionary-reference/573602/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":48,"encodingFormat":47,"isAccessibleForFree":49,"interactionStatistic":50},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/dictionaries-cheat-sheet-quick-python-dictionary-reference/573602.png","ImageObject",442,249,{"name":42,"@type":43},"Aldword","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-14",true,{"@type":51,"interactionType":52,"userInteractionCount":22},"InteractionCounter",{"@type":53},"ViewAction",{"@type":55,"mainEntity":56},"FAQPage",[57,63,67,71],{"name":58,"@type":59,"acceptedAnswer":60},"How do I create a Python dictionary and define key-value pairs?","Question",{"text":61,"@type":62},"Use curly braces with comma-separated entries like {'CA': 38332521, 'TX': 26448193}. Each entry follows the key:val form.","Answer",{"name":64,"@type":59,"acceptedAnswer":65},"How do I update or create a value for a key in a dictionary?",{"text":66,"@type":62},"Assign with a_dict[k] = exp. If k exists, the value is replaced; otherwise a new item with key k is created.",{"name":68,"@type":59,"acceptedAnswer":69},"What happens when I retrieve a value for a missing key?",{"text":70,"@type":62},"When retrieving with a_dict[k], it returns the value if the key exists; otherwise it raises a KeyError.",{"name":72,"@type":59,"acceptedAnswer":73},"How do I iterate over a dictionary and get its keys, values, or items?",{"text":74,"@type":62},"A dict is iterable over its keys. Use for var in a_dict for key iteration, a_dict.keys() for keys, a_dict.values() for values, and a_dict.items() for key-value pairs.","https://schema.org",{"og:url":32,"og:type":77,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":79,"canonical":32},"index,follow",{"doc_id":81,"site_id":7},573602,1792015505,{"code":4,"msg":84,"data":85},"success",[86,90,95,100,105,110,115,120,125],{"id":87,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":88,"slug":89},11,90,"presentations",{"id":91,"doc_module":22,"doc_module_name":25,"category_name":92,"show_sort_weight":93,"slug":94},12,"Resumes",80,"resumes",{"id":96,"doc_module":22,"doc_module_name":25,"category_name":97,"show_sort_weight":98,"slug":99},14,"Invoices",70,"invoices",{"id":101,"doc_module":22,"doc_module_name":25,"category_name":102,"show_sort_weight":103,"slug":104},15,"Posters",60,"posters",{"id":106,"doc_module":22,"doc_module_name":25,"category_name":107,"show_sort_weight":108,"slug":109},16,"Social Media",50,"social-media",{"id":111,"doc_module":22,"doc_module_name":25,"category_name":112,"show_sort_weight":113,"slug":114},17,"Forms",40,"forms",{"id":116,"doc_module":22,"doc_module_name":25,"category_name":117,"show_sort_weight":118,"slug":119},18,"Letters",30,"letters",{"id":121,"doc_module":22,"doc_module_name":25,"category_name":122,"show_sort_weight":123,"slug":124},21,"Paper Templates",5,"papers-templates",{"id":126,"doc_module":22,"doc_module_name":25,"category_name":127,"show_sort_weight":4,"slug":128},158,"General","general-158",{"code":4,"msg":84,"data":130},{"doc_id":81,"user_id":131,"nickname":42,"user_avatar":132,"doc_module":22,"category_id":87,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":133,"file_id":134,"file_url":135,"file_type":136,"file_size":137,"view_count":22,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":22,"language":138,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":139,"faqs":140,"seo_title":141,"seo_description":12,"update_tm":142,"read_time":4},2336478940917,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","Dictionaries Cheat Sheet  \nA Python dictionary (dict) is a special container type. It contains a collection of items, which are called key-value pairs and have the following form  \nkey:val  \nThe key in an item must be an immutable object and the val can be any type of object. The items contained in a dictionary are delimited by curly braces ({and }) and separated by commas. For example,  \nA = { 'CA ' : 38332521 , 'TX ' :26448193, 'MI ' :9895622} creates a new dict containing 3 items and assigns variable A a reference to it. The keys in a dictionary are used to retrieve and update values, and to create items.  \n• To create an item or update a value for a key: a_dict[k] = exp  \nIfa_dict contains an item whose key equals k, then the assignment replaces the value in this item with the value of exp; otherwise, the assignment creates an item with key equal to k and value equal to exp and adds this new item to a_dict.  \n• To retrieve a value: when not on the left-side of an assignment, a_dict[k] returns the value in the item in a_dict whose key equals k; or raises a KeyError, ifa_dict does not contain any item whose key equals k.  \nA dict is iterable; but you iterate through a dict using its keys.  \nexp in a_dict: returns True if exp is a key in a_dict; and False, otherwise.  \nfor var in a_dict: iterates through the keys ofa_dict , assigning each key  \nto var in its turn and executing the associated suite  \nlen(a_dict) : returns the number of items in a_dict  \nmax(a_dict): returns the maximum key in a_dict  \nmin(a_dict): returns the minimum key in a_dict  \na_dict.keys(): returns the collection (iterable) of keys in a_dict  \na_dict.values() : returns the collection (iterable) of values in a_dicta_dict.items() : returns the collection (iterable) of items in a_dict del a_dict[exp]: deletes the item in a_dict whose key equals exp","cbCaidILF73Cyi0f","https://ap.wps.com/l/cbCaidILF73Cyi0f","pdf",58661,"English","# Dictionary basics\n## Key-value pairs and syntax\n# Dictionary operations\n## Create, update, retrieve, delete\n# Dictionary iteration and utilities\n## Membership, looping, len/max/min, keys/values/items","[{\"question\":\"How do I create a Python dictionary and define key-value pairs?\",\"answer\":\"Use curly braces with comma-separated entries like {'CA': 38332521, 'TX': 26448193}. Each entry follows the key:val form.\"},{\"question\":\"How do I update or create a value for a key in a dictionary?\",\"answer\":\"Assign with a_dict[k] = exp. If k exists, the value is replaced; otherwise a new item with key k is created.\"},{\"question\":\"What happens when I retrieve a value for a missing key?\",\"answer\":\"When retrieving with a_dict[k], it returns the value if the key exists; otherwise it raises a KeyError.\"},{\"question\":\"How do I iterate over a dictionary and get its keys, values, or items?\",\"answer\":\"A dict is iterable over its keys. Use for var in a_dict for key iteration, a_dict.keys() for keys, a_dict.values() for values, and a_dict.items() for key-value pairs.\"}]","Dictionaries Cheat Sheet - Quick Python Dictionary Reference | PDF",1791943280]