{"id":8580,"date":"2020-05-25T15:12:58","date_gmt":"2020-05-25T09:42:58","guid":{"rendered":"https:\/\/tutorials.eyehunts.com\/?p=8580"},"modified":"2021-05-18T23:23:33","modified_gmt":"2021-05-18T17:53:33","slug":"python-slice-function-1-shorthand-array-list-tuple-string","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/","title":{"rendered":"Python slice Function |::-1 shorthand, (Array, List, Tuple, String)"},"content":{"rendered":"\n<p>Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple, etc. Means slice object is used to specify how to slice a sequence like <a rel=\"noreferrer noopener\" href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-strings-tutorial-example\/\" target=\"_blank\">strings<\/a>,&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-lists-tutorial-example\/\">lists<\/a>,&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-tuples-tuorial-example\/\" target=\"_blank\">tuples<\/a>.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Syntax<\/strong><\/h3>\n\n\n\n<pre>\nslice(start, stop, step)\n<\/pre>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Parameters<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>start <\/strong>\u00a0&#8211; The slicing of the object starts. Optional and  Default is NONE.<\/li><li><strong>stop<\/strong>\u00a0&#8211; The slicing stops at index\u00a0<strong>stop -1 (last element)<\/strong> and it&#8217;s required. <\/li><li><strong>step<\/strong>\u00a0&#8211; Determines the increment between each index for slicing. Optional and Default is NONE.<\/li><\/ul>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Return value:<\/strong><\/h3>\n\n\n\n<p>It returns a slice object.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example of Python slice Function<\/strong><\/h2>\n\n\n\n<p>Let&#8217;s do coding:-<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Create a slice object<\/strong><\/h3>\n\n\n\n<pre>\n# contains indices (0, 1, 2)\nobj1 = slice(3)\nprint(obj1)\n \n# contains indices (1, 3)\nobj2 = slice(1, 5, 2)\nprint(slice(1, 5, 2))\n<\/pre>\n\n\n\n<p><strong>Output: <\/strong><\/p>\n\n\n\n<p>slice(None, 3, None)<br>slice(1, 5, 2)<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>String slicing<\/strong><\/h3>\n\n\n\n<p>Example of python slice&nbsp;<strong>string<\/strong>. First create a slice object and then use to it slice string. Passing only stop value.<\/p>\n\n\n\n<pre>\n# String slicing\nstr = 'Hello World'\ns_obj = slice(5)\n\nprint(str[s_obj])\n\n<\/pre>\n\n\n\n<p><strong>Output: <\/strong>Hello<\/p>\n\n\n\n<p><strong>Read more:<\/strong> <a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-slice-string-function-get-range-characters-substring\/\">Python slice string Examples<\/a><\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. List slicing<\/strong><\/h3>\n\n\n\n<pre>Lst = [1, 2, 3, 4, 5]\ns_obj = slice(3)\n\nprint(Lst[s_obj])\n<\/pre>\n\n\n\n<p><strong>Output: <\/strong>[1, 2, 3]<\/p>\n\n\n\n<p><strong>Read more:<\/strong> <a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-list-slice-get-specific-sets-of-sub-elements\/\">Python list slice | Get specific sets of sub-elements Array<\/a><\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Tuple slicing<\/strong><\/h3>\n\n\n\n<p>Same as String and list you can slice tuple:-<\/p>\n\n\n\n<pre>\n# Tuple slicing \nTup = (1, 2, 3, 4, 5)\ns_obj = slice(3)\n\nprint(Tup[s_obj])\n\n<\/pre>\n\n\n\n<p><strong>Output:<\/strong> (1, 2, 3)<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Python slice&nbsp;shorthand<\/strong> | Understanding slice notation <\/h3>\n\n\n\n<p>Slice notation is used to extract a substring.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a&#91;start:stop]  # items start through stop-1\na&#91;start:]      # items start through the rest of the array\na&#91;:stop]       # items from the beginning through stop-1\na&#91;:]           # a copy of the whole array<\/code><\/pre>\n\n\n\n<p>There is also the&nbsp;<code>step<\/code>&nbsp;value, which can be used with any of the above:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a&#91;start:stop:step] # start through not past stop, by step<\/code><\/pre>\n\n\n\n<p><em><strong>List Slicing Shorthand<\/strong><\/em><\/p>\n\n\n\n<pre>\nli = ['a', 'b', 'Python', 'z', 'Tutorial']\nprint(li[:3])\n\nprint(li[3:])\n\nprint(li[:])\n\n<\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>[&#8216;a&#8217;, &#8216;b&#8217;, &#8216;Python&#8217;]<br>[&#8216;z&#8217;, &#8216;Tutorial&#8217;]<br>[&#8216;a&#8217;, &#8216;b&#8217;, &#8216;Python&#8217;, &#8216;z&#8217;, &#8216;Tutorial&#8217;]<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>::-1<\/strong>&nbsp;python Slice Notation <\/h3>\n\n\n\n<p>You can now easily extract the elements of a list that have even indexes:<\/p>\n\n\n\n<p>This also works for List, arrays, and strings:<\/p>\n\n\n\n<pre>\n# Tuple slicing\nTup = (1, 2, 3, 4, 5)\nprint(Tup[::2])\n\n<\/pre>\n\n\n\n<p><strong>Output: <\/strong>(1, 3, 5)<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Q: How to Python slice&nbsp;list by value<\/strong><\/h3>\n\n\n\n<p><strong>Answer<\/strong>: Use\u00a0<code>bisect<\/code><a rel=\"noreferrer noopener\" href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-modules-import-custom-builtin-package\/\" target=\"_blank\"> module<\/a>\u00a0as part of the standard library. See the below example for slice the list by value in python.<\/p>\n\n\n\n<pre>\nimport bisect\n \nlst = [1, 3, 5, 6, 8, 9, 11, 13, 17]\nfor val in range(19):\n    pos = bisect.bisect_right(lst, val)\n    print(val, '->', lst[max(0, pos - 3):pos])\n<\/pre>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-medium\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"248\" height=\"300\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png?resize=248%2C300&#038;ssl=1\" alt=\"Python slice Function\" class=\"wp-image-8625\" srcset=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-list-slice.png?resize=248%2C300&amp;ssl=1 248w, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-list-slice.png?w=714&amp;ssl=1 714w\" sizes=\"auto, (max-width: 248px) 100vw, 248px\" \/><\/figure><\/div>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Python&nbsp;list&nbsp;slice&nbsp;loop<\/strong><\/h3>\n\n\n\n<p>This code snippet to be very interesting.<\/p>\n\n\n\n<pre>\na = [0, 1, 2, 3]\n\nfor a[-1] in a:\n    print(a)\n<\/pre>\n\n\n\n<p><strong>Output: <\/strong><\/p>\n\n\n\n<p>[0, 1, 2, 0]<br>[0, 1, 2, 1]<br>[0, 1, 2, 2]<br>[0, 1, 2, 2]<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts and suggestion on this tutorial.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong><br>IDE:\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>\u00a02020.1.1 (Community Edition)<br>macOS 10.15.4<br><strong>Python 3.7<\/strong><br>All<strong>\u00a0Python Examples\u00a0are in\u00a0Python\u00a03<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple, etc. Means slice object is used to specify how to slice a sequence like strings,&nbsp;lists,&nbsp;tuples. Syntax slice(start, stop, step) Parameters start \u00a0&#8211; The slicing of the object starts. Optional and Default is NONE. stop\u00a0&#8211; The slicing stops at index\u00a0stop&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python slice Function |::-1 shorthand, (Array, List, Tuple, String)<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[38,102],"post_series":[],"class_list":["post-8580","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-function","tag-python-slice"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python slice Function |::-1 shorthand, (Array, List, Tuple, String) - EyeHunts<\/title>\n<meta name=\"description\" content=\"Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple. Means slice object is used to specify how to slice\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python slice Function |::-1 shorthand, (Array, List, Tuple, String) - EyeHunts\" \/>\n<meta property=\"og:description\" content=\"Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple. Means slice object is used to specify how to slice\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-25T09:42:58+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-18T17:53:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/\",\"name\":\"Python slice Function |::-1 shorthand, (Array, List, Tuple, String) - EyeHunts\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png\",\"datePublished\":\"2020-05-25T09:42:58+00:00\",\"dateModified\":\"2021-05-18T17:53:33+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple. Means slice object is used to specify how to slice\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#primaryimage\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python slice Function |::-1 shorthand, (Array, List, Tuple, String)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python slice Function |::-1 shorthand, (Array, List, Tuple, String) - EyeHunts","description":"Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple. Means slice object is used to specify how to slice","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:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/","og_locale":"en_US","og_type":"article","og_title":"Python slice Function |::-1 shorthand, (Array, List, Tuple, String) - EyeHunts","og_description":"Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple. Means slice object is used to specify how to slice","og_url":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/","og_site_name":"Tutorial","article_published_time":"2020-05-25T09:42:58+00:00","article_modified_time":"2021-05-18T17:53:33+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/","url":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/","name":"Python slice Function |::-1 shorthand, (Array, List, Tuple, String) - EyeHunts","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png","datePublished":"2020-05-25T09:42:58+00:00","dateModified":"2021-05-18T17:53:33+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Python slice function returns a slice object that can use used to slice strings, lists(Array), tuple. Means slice object is used to specify how to slice","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#primaryimage","url":"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png","contentUrl":"https:\/\/tutorial.eyehunts.com\/\/wp-content\/uploads\/2020\/05\/Python-list-slice-248x300.png"},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-function-1-shorthand-array-list-tuple-string\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Python slice Function |::-1 shorthand, (Array, List, Tuple, String)"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":8584,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-slice-string-function-get-range-characters-substring\/","url_meta":{"origin":8580,"position":0},"title":"Python slice string Function| Get a range of characters (SubString)","author":"Rohit","date":"May 24, 2020","format":false,"excerpt":"You can get a range of characters(substring) by using the slice function. Python slice() function returns a slice object that can use used to slice strings, lists, tuples. You have to Specify the parameters- start index and the end index, separated by a colon, to return a part of the\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-slice-string-Function-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-slice-string-Function-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-slice-string-Function-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-slice-string-Function-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":17749,"url":"https:\/\/tutorial.eyehunts.com\/python\/slice-tuple-python-example-code\/","url_meta":{"origin":8580,"position":1},"title":"Slice tuple Python | Example code","author":"Rohit","date":"November 10, 2021","format":false,"excerpt":"Use the [] operator on the tuple to Slice the tuple in Python. If using a positive number, it slices that index from the tuple counting from the left. Or if it's a negative number, it fetches that index from the tuple counting from the right. If you want to\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Slice tuple Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Slice-tuple-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17733,"url":"https:\/\/tutorial.eyehunts.com\/python\/slice-operator-in-python-basics\/","url_meta":{"origin":8580,"position":2},"title":"Slice operator in Python | Basics","author":"Rohit","date":"November 10, 2021","format":false,"excerpt":"Slice operators are nothing bracket [] used with 3 values to slice string, tuple, or list in Python. The three-parameter is used in the slice operator is:- start = include everything STARTING AT this idx (inclusive) stop = include everything BEFORE this idx (exclusive) step = (can be ommitted) difference\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Slice operator in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Slice-operator-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":41289,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-ellipsis\/","url_meta":{"origin":8580,"position":3},"title":"Python ellipsis","author":"Rohit","date":"July 26, 2023","format":false,"excerpt":"In Python, the ellipsis (...) is a special object called \"ellipsis\" or \"ellipsis literal.\" It is represented by three consecutive dots and is used as a placeholder or sentinel value in various contexts. The ellipsis is also sometimes referred to as a \"triple-dot operator\" or \"suspension points\". Slice Notation: The\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/07\/Python-ellipsis.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":20824,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-extend-tuple-example-code\/","url_meta":{"origin":8580,"position":4},"title":"Python extend tuple | Example code","author":"Rohit","date":"October 9, 2021","format":false,"excerpt":"There's no append() or extend() method for tuples in Python. Tuples are immutable data types so you can't remove the element from it. However, you can extend the tuple using concatenate or slice method. Python extend tuple example Simple example code to will not extend tuples but form new tuples:\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python extend tuple","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-extend-tuple.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17741,"url":"https:\/\/tutorial.eyehunts.com\/python\/start-stop-step-python-slice-parameters\/","url_meta":{"origin":8580,"position":5},"title":"Start Stop Step Python | slice() Parameters","author":"Rohit","date":"August 12, 2021","format":false,"excerpt":"The slice method has 3 notations - Start Stop Step in Python. slice(start: stop[: step]) is an object usually containing a portion of a sequence. This function can be used to slice tuples, arrays, sentences, and lists. Here is the syntax of the slice() method. slice(start, stop, step) start (optional)-\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Start Stop Step Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Start-Stop-Step-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/8580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=8580"}],"version-history":[{"count":0,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/8580\/revisions"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=8580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=8580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=8580"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=8580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}