{"id":569,"date":"2023-02-08T23:55:17","date_gmt":"2023-02-08T23:55:17","guid":{"rendered":"http:\/\/yesrenee.com\/?p=569"},"modified":"2023-08-28T18:00:44","modified_gmt":"2023-08-28T18:00:44","slug":"python-index","status":"publish","type":"post","link":"https:\/\/yesrenee.com\/?p=569","title":{"rendered":"Python Index"},"content":{"rendered":"\n<p>Indexes are perfect to use in Python when you have to locate a certain part in a string.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>abc = \"a b c\"\r\nindex = abc.index(\"b\")\r\nprint(\"Index of substring:\", index)\r\n<\/code><\/pre>\n\n\n\n<p>In the code above, <em>abc<\/em> is put into <em>index<\/em> of <em>abc<\/em>. The quotations say b, so where is b? Start from the start, and count. <em>a<\/em> is 1, space is 2, <em>b<\/em> is 3. So <em>b<\/em> is located in 3.<\/p>\n\n\n\n<p>Here is another example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>q = \"queue\"\nn = q.index(\"u\")\nprint(\"n\")<\/code><\/pre>\n\n\n\n<p>Now we find &#8220;u&#8221; in queue. q is 1. u is 2. So print 2. We don&#8217;t print 4 because that u is after.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Indexes are perfect to use in Python when you have to locate a certain part in a string. For example: In the code above, abc is put into index of abc. The quotations say b, so where is b? Start from the start, and count. a is 1, space is 2, b is 3. So [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[19],"class_list":["post-569","post","type-post","status-publish","format-standard","hentry","category-daily","tag-python-programming"],"_links":{"self":[{"href":"https:\/\/yesrenee.com\/index.php?rest_route=\/wp\/v2\/posts\/569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yesrenee.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yesrenee.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yesrenee.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yesrenee.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=569"}],"version-history":[{"count":1,"href":"https:\/\/yesrenee.com\/index.php?rest_route=\/wp\/v2\/posts\/569\/revisions"}],"predecessor-version":[{"id":570,"href":"https:\/\/yesrenee.com\/index.php?rest_route=\/wp\/v2\/posts\/569\/revisions\/570"}],"wp:attachment":[{"href":"https:\/\/yesrenee.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yesrenee.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yesrenee.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}