<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lazy Code Crafters</title>
    <description>The latest articles on DEV Community by Lazy Code Crafters (@lazycodecrafters).</description>
    <link>https://dev.to/lazycodecrafters</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2861026%2F5d49300d-2ab2-4c50-ae17-530d45542bd6.png</url>
      <title>DEV Community: Lazy Code Crafters</title>
      <link>https://dev.to/lazycodecrafters</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lazycodecrafters"/>
    <language>en</language>
    <item>
      <title>Find Capital Indexes</title>
      <dc:creator>Lazy Code Crafters</dc:creator>
      <pubDate>Fri, 14 Feb 2025 05:31:15 +0000</pubDate>
      <link>https://dev.to/lazycodecrafters/find-capital-indexes-40pm</link>
      <guid>https://dev.to/lazycodecrafters/find-capital-indexes-40pm</guid>
      <description>&lt;p&gt;Write a function named &lt;strong&gt;capital_indexes&lt;/strong&gt;. The function takes a single parameter, which is a &lt;strong&gt;string&lt;/strong&gt;. Your function should &lt;em&gt;return a list of all the indexes in the string that have capital letters&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;For example, calling &lt;strong&gt;capital_indexes("HeLlO")&lt;/strong&gt; should &lt;strong&gt;return the list [0, 2, 4]&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is the &lt;strong&gt;challenge&lt;/strong&gt; here. There are many ways to achieve it as you know in programming you can achieve a result using different methods. The main takeaway is your method should be good not some junk and throwing different methods and functions here and there.&lt;/p&gt;

&lt;p&gt;So I solved this problem with two different approach. One is how I think a beginner will try to do and other is an experienced python programmer will do.&lt;/p&gt;

&lt;p&gt;So let's check them both.......&lt;/p&gt;

&lt;h2&gt;
  
  
  The Beginner Way
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F228xxdqu0r84qqivvmo2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F228xxdqu0r84qqivvmo2.png" alt="Image description" width="516" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here we're taking a variable &lt;strong&gt;val&lt;/strong&gt; as a &lt;strong&gt;list&lt;/strong&gt; and then using for loop on our &lt;strong&gt;word&lt;/strong&gt; parameter. After that we are checking &lt;strong&gt;if the character is capital or not&lt;/strong&gt; if it is then we will take its index and append in our val variable. At last we will return the val variable and that's it.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a beginner approach. Now let's lok how an experienced programmer will handle this.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Experienced Way
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F781skszp9q2d3ynwsldr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F781skszp9q2d3ynwsldr.png" alt="Image description" width="457" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;_In this approach we're using &lt;strong&gt;list comprehension&lt;/strong&gt; to first loop over our word. And we are using &lt;strong&gt;enumerate&lt;/strong&gt; method so we can get the &lt;strong&gt;index as well as the character&lt;/strong&gt;. After looping we are checking &lt;strong&gt;if the character is capital or not&lt;/strong&gt;; if it is then we'll take its index and return it. That's it.&lt;br&gt;
_&lt;br&gt;
I hope you liked how I have solved it. If you will solve this problem any way and that's better than this please let me know. I'd love to know.&lt;/p&gt;

&lt;p&gt;Thank You!!!&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
