{"id":12260,"date":"2020-09-16T04:55:14","date_gmt":"2020-09-16T11:55:14","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=12260"},"modified":"2023-12-01T03:59:41","modified_gmt":"2023-12-01T11:59:41","slug":"python-tuples","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/python-tuples\/","title":{"rendered":"Python Tuples: A Step-By-Step Guide"},"content":{"rendered":"\n<p><em>Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>Tuples are a core data structure in <a href=\"https:\/\/careerkarma.com\/blog\/what-python-is-used-for\/\">Python<\/a>. They let you store an ordered <a href=\"https:\/\/careerkarma.com\/blog\/fibonacci-sequence-python\/\">sequence<\/a> of items. For example, you may use a tuple to store a list of employee names. You could use a tuple to store a list of ice cream flavors stocked at an ice cream shop.<\/p>\n\n\n\n<p>In this tutorial, we are going to break down the basics of the tuple data type. We\u2019ll discuss its purpose and provide examples to demonstrate how you can work with this data type.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding Python Tuples<\/h2>\n\n\n\n<p>Tuples are immutable, ordered lists of data, unlike lists. Lists are mutable, which means you can change the contents of a list. Individual values in a tuple are called <em>items.<\/em> Tuples can store any data type.<\/p>\n\n\n\n<p>A tuple is a comma-separated sequence of items. This sequence is surrounded by parenthesis <em>(())<\/em>. Let&#8217;s create a tuple:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = ('Chocolate', 'Vanilla', 'Mint', 'Strawberry', 'Choc-Chip')<\/pre><\/div>\n\n\n\n<p>When we print our tuple to the console using the <em>print()<\/em><a href=\"https:\/\/careerkarma.com\/blog\/python-functions\/\">function<\/a>, we will see the tuple that we originally declared. The values in our tuple are separated by commas:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(tuple)<\/pre><\/div>\n\n\n\n<p>Our code returns the following: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>('Chocolate', 'Vanilla', 'Mint', 'Strawberry', 'Choc-Chip')<\/pre><\/div>\n\n\n\n<p>Tuples store data with a common theme, similar to lists. In the above example, our tuple stores a collection of ice cream flavors. It could also store a list of student grades or a list of phones sold by an electronics store, for instance.<\/p>\n\n\n\n<p>Tuples are similar to <a href=\"https:\/\/careerkarma.com\/blog\/python-array\/\">Python lists<\/a>, with one big difference: you cannot modify a tuple. You should only use tuples when you want a list to remain the same. If we wanted to add flavors to our ice cream flavors list above, a regular list would likely be better. This is because we could change the contents of the list as our ice cream flavors change.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Access Tuple Items<\/h2>\n\n\n\n<p>Each item in a tuple has a unique <a href=\"https:\/\/careerkarma.com\/blog\/python-index\/\">index<\/a> value, starting with zero. Index values continue in increments of one. You can access an individual item in a tuple by referencing the item\u2019s index value.<\/p>\n\n\n\n<p>Here are the index values for the <em>ice_cream_flavors<\/em> tuple that we declared above:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>Chocolate<\/td><td>Vanilla<\/td><td>Mint<\/td><td>Strawberry<\/td><td>Choc-Chip<\/td><\/tr><tr><td>0<\/td><td>1<\/td><td>2<\/td><td>3<\/td><td>4<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>Now that we know the index values for each item, we can access a single element individually. The following code allows us to get the item at the index value <em>3<\/em>:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(ice_cream_flavors[3])<\/pre><\/div>\n\n\n\n<p>Our code returns: <em>Strawberry<\/em>. <em>Strawberry<\/em> is the item whose index value is 3.<\/p>\n\n\n\n<p>Each item in a tuple has a negative index value. These values let us count backward from the end of a tuple. They start at <em>-1<\/em>. Using a negative index number may be more convenient if you are working with a long list. This is because you can work backwards from the end of the list.<\/p>\n\n\n\n<p>Here are the negative index values for our <em>ice_cream_flavors<\/em> tuple:<\/p>\n\n\n\n<table class=\"wp-block-table course-info-table\"><tbody><tr><td>Chocolate<\/td><td>Vanilla<\/td><td>Mint<\/td><td>Strawberry<\/td><td>Choc-Chip<\/td><\/tr><tr><td>-5<\/td><td>-4<\/td><td>-3<\/td><td>-2<\/td><td>-1<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>If we wanted to get the value at the index position of <code>-1<\/code>, we could use the following code: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(ice_cream_flavors[-1])<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>Choc-Chip<\/code>. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tuple Slicing<\/h2>\n\n\n\n<p>Similarly, if we want to get a range of items within our tuple, we can specify a range of indexes to retrieve. In order to do so, we need to specify where to start and end our range. We can use the following code to retrieve every item in the range of the 1 and 4 index values:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(ice_cream_flavors[1:4])<\/pre><\/div>\n\n\n\n<p>Our code returns: <em>(\u2018Vanilla\u2019, \u2018Mint\u2019, \u2018Strawberry\u2019)<\/em><\/p>\n\n\n\n<p>In this example, our code returns every value with an index value between <em>1<\/em> and <em>4<\/em>, exclusive of the last index value. Our code does not return <em>Choc-Chip<\/em> because <em>Choc-Chip<\/em> does not appear in the defined range.<\/p>\n\n\n\n<p>If we wanted to retrieve items from either end of the list, we can remove the first number in our range. So, if we wanted to get the first two items in our list, we could use the following Python program:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(ice_cream_flavors[:2])<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>(\u2018Vanilla\u2019, \u2018Mint\u2019)<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Slicing with Negative Index Numbers<\/h2>\n\n\n\n<p>In addition, you can use negative index numbers when you\u2019re slicing tuples. The below example returns the last two items in our list: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(ice_cream_flavors[-2:])<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>('Strawberry', 'Choc-Chip')<\/code> <\/p>\n\n\n\n<p>There is also a feature of tuple slicing called&nbsp;<strong>stride.<\/strong>&nbsp;This feature allows us to skip over items after the first item is retrieved from a tuple. If we want to use stride, we can add a value to the end of our slicing function. This states how many items the list should skip over between increments.<\/p>\n\n\n\n<p>So if we wanted to get every second number in our tuple, we could use the following code:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>print(ice_cream_flavors[0:5:2])<\/pre><\/div>\n\n\n\n<p>Our code returns: <code>('Chocolate', 'Mint', 'Choc-Chip')<\/code><\/p>\n\n\n\n<p>The first number in our slice <em>(0)<\/em> refers to when the slice should start in the array. 5 refers to the final item our slice should reference, exclusive of that item. The third number (<em>2<\/em>) refers to the stride we want to use. Stride represents how many values after the first item the code should skip over when slicing a tuple.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tuple Operators<\/h2>\n\n\n\n<p>You can use operators to concatenate (merge) or multiply the contents of a tuple. Additionally, the&nbsp;<em>+<\/em>&nbsp;operator can be used to concatenate two or more together.<\/p>\n\n\n\n<p>Let\u2019s say that we have a list of ice cream flavors. We want to add the experimental flavors we have been piloting to the main list of flavors. We could use the following code to merge our tuples:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = ('Chocolate', 'Vanilla', 'Mint', 'Strawberry', 'Choc-Chip')\nexperimental_flavors = ('Cookie Dough', 'Rocky Road', 'Mint Chocolate Chip')\nnew_menu = ice_cream_flavors + experimental_flavors\n\nprint(new_menu)<\/pre><\/div>\n\n\n\n<p>Our code returns the following: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>('Chocolate', 'Vanilla', 'Mint', 'Strawberry', 'Choc-Chip', 'Cookie Dough','Rocky Road', 'Mint Chocolate Chip')<\/pre><\/div>\n\n\n\n<p>As you can see, we now have a new tuple that contains values from both lists. However, because a tuple cannot be modified, we created a new one called <em>new_menu<\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Iterating Through a Tuple<\/h2>\n\n\n\n<p>Like lists, you can iterate through a tuple value in Python. So, if you had a tuple of ice cream flavors that you wanted to print individually, you could do so.<\/p>\n\n\n\n<p>Here\u2019s an example of a <em>for<\/em> loop being used to iterate through our ice cream flavors tuple and prints each value:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = ('Chocolate', 'Vanilla', 'Mint', 'Strawberry', 'Choc-Chip')\nfor f in ice_cream_flavors:\n\tprint(f)<\/pre><\/div>\n\n\n\n<p>The result of our code is as follows: <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>Chocolate\nVanilla\nMint\nStrawberry\nChoc-Chip<\/pre><\/div>\n\n\n\n<p>You can check if an item exists in a tuple by using an <em>if&#8230;in<\/em> statement. An <em>if&#8230;in<\/em> statement checks whether a value exists in a collection. Here\u2019s an example of an <em>if&#8230;in<\/em> statement being used to check if our ice cream parlor sells <em>Mint<\/em> ice cream:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>ice_cream_flavors = ('Chocolate', 'Vanilla', 'Mint', 'Strawberry', 'Choc-Chip')\nif &quot;Mint&quot; in ice_cream_flavors:\n\tprint(&quot;Yes, we sell mint ice cream!&quot;)<\/pre><\/div>\n\n\n\n<p>Our code returns: Yes, we sell mint ice cream! This is because &#8220;Mint&#8221; is in our list.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lists vs. Tuples<\/h2>\n\n\n\n<p>Unlike lists, tuples cannot be modified. You cannot add, remove, or replace an item within a tuple. Using a list may be more appropriate if you intend to modify the values you want to store.<\/p>\n\n\n\n<p>That said, you can concatenate two or more tuples, which means that you can combine two tuples to form a new one.<\/p>\n\n\n\n<p>To modify the contents of a tuple, we need to convert it into a list. Then, we can convert our list back into a tuple. Here\u2019s how we could convert our new list of flavors to a list that we can modify:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>list(new_menu)<\/pre><\/div>\n\n\n\n<p>Our code returns a list. We can use the tuple() method to convert our value back to a tuple:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>tuple(new_menu)<\/pre><\/div>\n\n\n\n<p>Our menu is now stored as a tuple. We know this because our collection of items is surrounded by curly brackets. Curly brackets denote a tuple.<\/p>\n\n\n\n<iframe loading=\"lazy\" src=\"https:\/\/repl.it\/@careerkarma\/Python-Tuple?lite=true\" width=\"100%\" height=\"400px\" frameborder=\"0\"><\/iframe>\n<br>\n<br>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The tuple data type is an immutable, ordered data type that allows you to store data in Python. Tuples are somewhat faster to use than <a href=\"https:\/\/careerkarma.com\/blog\/python-list-methods\/\">lists<\/a> in Python because they cannot be changed. As such, they\u2019re useful if you need to store data that will not change.<\/p>\n","protected":false},"excerpt":{"rendered":"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis. Tuples are a core data structure in Python. They let you store an ordered sequence of items. For example, you may use a tuple&hellip;","protected":false},"author":240,"featured_media":12261,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16578],"tags":[],"class_list":{"0":"post-12260","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Python","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":null,"is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Python Tuples: A Step-By-Step Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/python-tuples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Tuples: A Step-By-Step Guide\" \/>\n<meta property=\"og:description\" content=\"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/python-tuples\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-16T11:55:14+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T11:59:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"668\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"Python Tuples: A Step-By-Step Guide\",\"datePublished\":\"2020-09-16T11:55:14+00:00\",\"dateModified\":\"2023-12-01T11:59:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/\"},\"wordCount\":1272,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-tuples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/\",\"name\":\"Python Tuples: A Step-By-Step Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg\",\"datePublished\":\"2020-09-16T11:55:14+00:00\",\"dateModified\":\"2023-12-01T11:59:41+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/python-tuples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg\",\"width\":1000,\"height\":668},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/python-tuples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/careerkarma.com\/blog\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Tuples: A Step-By-Step Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python Tuples: A Step-By-Step Guide | Career Karma","description":"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/careerkarma.com\/blog\/python-tuples\/","og_locale":"en_US","og_type":"article","og_title":"Python Tuples: A Step-By-Step Guide","og_description":"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.","og_url":"https:\/\/careerkarma.com\/blog\/python-tuples\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-09-16T11:55:14+00:00","article_modified_time":"2023-12-01T11:59:41+00:00","og_image":[{"width":1000,"height":668,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"Python Tuples: A Step-By-Step Guide","datePublished":"2020-09-16T11:55:14+00:00","dateModified":"2023-12-01T11:59:41+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/"},"wordCount":1272,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/python-tuples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/","url":"https:\/\/careerkarma.com\/blog\/python-tuples\/","name":"Python Tuples: A Step-By-Step Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg","datePublished":"2020-09-16T11:55:14+00:00","dateModified":"2023-12-01T11:59:41+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Python tuples are a data structure that store an ordered sequence of values. Tuples are immutable. This means you cannot change the values in a tuple. Tuples are defined with parenthesis.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/python-tuples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/02\/python-tuples.jpg","width":1000,"height":668},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/python-tuples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/careerkarma.com\/blog\/python\/"},{"@type":"ListItem","position":3,"name":"Python Tuples: A Step-By-Step Guide"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=12260"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/12260\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/12261"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=12260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=12260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=12260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}