{"id":39029,"date":"2016-11-23T08:20:20","date_gmt":"2016-11-23T14:20:20","guid":{"rendered":"http:\/\/a00344371.wordpress.com\/?p=295"},"modified":"2016-11-23T08:20:20","modified_gmt":"2016-11-23T14:20:20","slug":"python-lists-and-tuples","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/python-lists-and-tuples\/","title":{"rendered":"Python Lists and Tuples"},"content":{"rendered":"<p class=\"syndicated-attribution\"><em> --Originally published at <a href=\"https:\/\/a00344371.wordpress.com\/2016\/11\/23\/python-lists-and-tuples\/\"><a href=\"https:\/\/a00344371.wordpress.com\">Programming Fundaments<\/a><\/a><\/em><br \/><\/p>\n<p>These are the most common build-in data type for python. These are used to store objects or values in a specific order. These are really easy to create. Here:<\/p>\n<div id=\"crayon-5835a3b4e775d732901623-1\" class=\"crayon-line\"><span class=\"crayon-c\"># Lists must be surrounded by brackets<\/span><\/div>\n<div id=\"crayon-5835a3b4e775d732901623-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-v\">emptylst<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-sy\">[<\/span><span class=\"crayon-sy\">]<\/span><\/div>\n<div id=\"crayon-5835a3b4e775d732901623-3\" class=\"crayon-line\"><span class=\"crayon-c\"># Tuples may or may not be surrounded by parenthesis<\/span><\/div>\n<div id=\"crayon-5835a3b4e775d732901623-4\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-v\">emptytup<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-sy\">(<\/span><span class=\"crayon-sy\">)<\/span><\/div>\n<div class=\"crayon-line crayon-striped-line\"><\/div>\n<div class=\"crayon-line crayon-striped-line\">Those were empty list. To create non-empty lists or tuples, the values are separated by commas:<\/div>\n<div class=\"crayon-line crayon-striped-line\">\n<div class=\"crayon-line\"><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-1\" class=\"crayon-line\"><span class=\"crayon-c\"># Lists must be surrounded by brackets<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-2\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-v\">lst<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-sy\">[<\/span><span class=\"crayon-cn\">1<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">2<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">3<\/span><span class=\"crayon-sy\">]<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-3\" class=\"crayon-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-i\">lst<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-4\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-sy\">[<\/span><span class=\"crayon-cn\">1<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">2<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">3<\/span><span class=\"crayon-sy\">]<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-5\" class=\"crayon-line\"><span class=\"crayon-c\"># Tuples may or may not be surrounded by parenthesis<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-6\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-v\">tup<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-cn\">1<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">2<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">3<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-7\" class=\"crayon-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-e\">tup<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-8\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-sy\">(<\/span><span class=\"crayon-cn\">1<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">2<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-cn\">3<\/span><span class=\"crayon-sy\">)<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-9\" class=\"crayon-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-v\">tup<\/span> <span class=\"crayon-o\">=<\/span> <span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;one&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-s\">&#8216;two&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-s\">&#8216;three&#8217;<\/span><span class=\"crayon-sy\">)<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-10\" class=\"crayon-line crayon-striped-line\"><span class=\"crayon-o\">&gt;&gt;&gt;<\/span> <span class=\"crayon-e\">tup<\/span><\/div>\n<div id=\"crayon-5835a3b4e7764878666462-11\" class=\"crayon-line\"><span class=\"crayon-sy\">(<\/span><span class=\"crayon-s\">&#8216;one&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-s\">&#8216;two&#8217;<\/span><span class=\"crayon-sy\">,<\/span> <span class=\"crayon-s\">&#8216;three&#8217;<\/span><span class=\"crayon-sy\">)<\/span><\/div>\n<\/div>\n<div class=\"crayon-line\">\u00a0(To create a tuple with only one value, add a trailing comma to the value.)<\/div>\n<div class=\"crayon-line\"><\/div>\n<div class=\"crayon-line\">Example &amp; More at:\u00a0http:\/\/pythoncentral.io\/python-lists-and-tuples\/<\/div><br \/>  <a rel=\"nofollow\" href=\"http:\/\/feeds.wordpress.com\/1.0\/gocomments\/a00344371.wordpress.com\/295\/\"><img alt=\"\" border=\"0\" src=\"http:\/\/feeds.wordpress.com\/1.0\/comments\/a00344371.wordpress.com\/295\/\" \/><\/a> <img alt=\"\" border=\"0\" src=\"https:\/\/pixel.wp.com\/b.gif?host=a00344371.wordpress.com&#038;blog=115285426&%23038;post=295&%23038;subd=a00344371&%23038;ref=&%23038;feed=1\" width=\"1\" height=\"1\" \/>","protected":false},"excerpt":{"rendered":"<p>&#8211;Originally published at Programming Fundaments These are the most common build-in data type for python. These are used to store objects or values in a specific order. These are really easy to create. Here: # Lists must be surrounded by brackets &gt;&gt;&gt; emptylst = [] # Tuples may or may not be surrounded by parenthesis &hellip; <a href=\"https:\/\/kenscourses.com\/tc101fall2016\/syndicated\/python-lists-and-tuples\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Python Lists and Tuples<\/span><\/a><\/p>\n","protected":false},"author":16,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[37,24,33],"class_list":["post-39029","post","type-post","status-publish","format-standard","hentry","category-blogs","category-syndicated","tag-programming","tag-python","tag-tc101"],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/39029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/users\/16"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/comments?post=39029"}],"version-history":[{"count":4,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/39029\/revisions"}],"predecessor-version":[{"id":42146,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/posts\/39029\/revisions\/42146"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/media?parent=39029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/categories?post=39029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2016\/wp-json\/wp\/v2\/tags?post=39029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}