<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Cathlyn on Medium]]></title>
        <description><![CDATA[Stories by Cathlyn on Medium]]></description>
        <link>https://medium.com/@cathlynanderson?source=rss-1c6c302799cc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3dQwJrFuN5jHLI9yFbwFzw.jpeg</url>
            <title>Stories by Cathlyn on Medium</title>
            <link>https://medium.com/@cathlynanderson?source=rss-1c6c302799cc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 02:55:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@cathlynanderson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[My experience with ChatGPT as a Business Intelligence Developer]]></title>
            <link>https://cathlynanderson.medium.com/my-experience-with-chatgpt-as-a-business-intelligence-developer-b2ca6fbd25bb?source=rss-1c6c302799cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2ca6fbd25bb</guid>
            <category><![CDATA[power-bi]]></category>
            <category><![CDATA[dax]]></category>
            <category><![CDATA[chatgpt]]></category>
            <dc:creator><![CDATA[Cathlyn]]></dc:creator>
            <pubDate>Tue, 24 Jan 2023 05:38:15 GMT</pubDate>
            <atom:updated>2023-01-24T05:38:15.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*c3x_SNAB2KdWSeRpH4Ru-Q.png" /></figure><p>With all the hype and media exposure that ChatGPT has been receiving, it is difficult not to be curious about how much impact it could have on our professional lives. After reading various articles about how ChatGPT has been utilised to <a href="https://www.reddit.com/r/YouShouldKnow/comments/10hnf37/ysk_chatgpt_creates_a_web_application_in_5_seconds/">create quick simple applications in 5 seconds</a>, to how it has assisted with the tedious process of <a href="https://dev.to/codewithbernard/chatgpt-is-helping-me-do-code-reviews-3a0o">code reviews</a>, needless to say, I was very, very curious. So I gave it a try.</p><p>Getting started with ChatGPT is very simple, so I won’t bore you with it. For this experiment, I wanted ChatGPT to assist me with some Power BI DAX expression. If anyone has ever worked with DAX expression, you will know how painful it can be. Can ChatGPT help alleviate some of this pain?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*0ktoC640JGhU7pualZxZ5g.png" /></figure><p>I told ChatGPT what I wanted to work on some Power BI DAX and PowerQuery expressions. It responded by suggesting some ways that it can be helpful. Nice.</p><p>I have been working on some KPIs mock up recently for my UX design, so this was front of mind. I quickly told ChatGPT a basic structure of some tables that you might have to store KPIs data for reporting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*i-dYCSjbXVmmIHvvJwzj1Q.png" /></figure><p>One of the nice features of ChatGPT is the ability to remember the context of the conversation that you are having with it. After I gave it the outline for the first table, it remembered to ask me about the other two tables in the workbook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*rm_3ZHXbVpes0yIf2OSaHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*_fTtcey0w7sZdhC4VLlonQ.png" /></figure><p>Now that the table outline have been set, let’s give ChatGPT some more context to make sure that the expressions that it come up with later is relevant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*Ezfvh5QBaZ9WCMVKWwzPeQ.png" /></figure><p>Wow, that was helpful!</p><p>Let’s get started. When talking about dates, one of the most annoying calculation that I’ve had to write many many times (in multiple languages) is the calculation to get the Start/End of the Current/Next/Previous Financial Year. So that’s the task that I gave to ChatGPT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*ShJF2crSlWB2KxizW3e-Fg.png" /></figure><p>Now, if I were to put this into Power BI and validate this with some dummy data, this is the result that I get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*r6Y-M_1O1br2ykfQ2B9CRA.png" /></figure><p>Did anyone spot anything interesting? The values that this expression returned is not correct. What it has given us is the end of the previous Financial Year.</p><p>Let’s switch things up a bit. How about asking ChatGPT to review our code now?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*lChReJAQS77CpLodu7HeJA.png" /></figure><p>If I put the two calculated columns next to each other, EoFY2 is the one using the expression provided by ChatGPT, and EoFY<em> </em>is the expression that I have written, you can see the difference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*fafJDKEDJCnLUyS-Pv5Chw.png" /></figure><p>From what I have seen in other articles, though, ChatGPT can be trained. So if it provides the incorrect answer, you should be able to tell it that it was wrong and let it learn.</p><p>Next, let’s give it something a little harder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*kvJerYWSYRMx3rymsjLNSQ.png" /></figure><p>Has anyone spot the issue yet?</p><p>In the expression above, ChatGPT is using the CONCATENATE function, which isn’t a bad idea. However, the CONCATENATE function in DAX can only take 2 arguments. If you were to input this into Power BI, you would get the following error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*tmoFPsdi50DyWkXQjVOkoQ.png" /></figure><p>ChatGPT should NEVER be used as the solution to your problems. At most, it can be considered as an assistant, but even then, I wouldn’t blindly trust everything that it tells you.</p><p>I mentioned earlier that ChatGPT should be able to learn from its mistakes, once it is made aware of it. So that’s what I did next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*wnrEx17g9AUaO0ofaFYesw.png" /></figure><p>ChatGPT acknowledged its mistake and even explained why this error came about, and at the same time, provided us with an updated expression. When I input this expression into Power BI, this is the result that I get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*O08hJrRvebF7FolkK8P6xQ.png" /></figure><p>It is almost there. The first part of the expression is returning the correct year, however, the second half is not returning the correct year for all the records. This is most likely because of this:</p><pre>RIGHT(YEAR(KPI_Results[Reporting Date To])+1, 2)</pre><p>This is adding another year to the Reporting Date To by default, regardless of what month the Report Date To is in, thus disregarding the Financial Year. More fine-tuning is required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*fBamtLdZjt7OuqwncB9DDw.png" /></figure><p>We can see from the above that ChatGPT is now taking into account the month of the Reporting Date To. Let’s see what result we get in Power BI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*PzYxo4rIx6A4OzrFeDlwTQ.png" /></figure><p>Unfortunately, the data still doesn’t look right. Let’s see if we can get ChatGPT to correct itself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*LP--nHS_p_ZORjrIUszqbA.png" /></figure><p>Luckily, this time it provided the correct answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*V9N-Vx6ceoMZOuSz-6p_jA.png" /></figure><p>Was there any other way we could have written this to provide the same result? Yes, there are many solutions that we can come up with that will provide us with the correct result. For example:</p><pre>Financial Year = <br>    VAR SoFY = DATE( IF(MONTH(KPI_Results[Reporting Date To]) &gt;= 7, YEAR(KPI_Results[Reporting Date To]), YEAR(KPI_Results[Reporting Date To])-1), 7, 1)<br>    RETURN CONCATENATE(YEAR(SoFY), CONCATENATE(&quot;/&quot;, RIGHT(YEAR(KPI_Results[EoFY]), 2)))</pre><p>The above expression take advantage of the EoFY calculated field that we created earlier, and at the same time, create an inline variable called SoFY that returns the Start of the Financial Year based on the Reporting Date To. With these two values, Start and End of the Financial Year, it is then a simple matter of concatenating the two together using 2 CONCATENATE.</p><p>Continuing with the ChatGPT’s ability to remember contextual information, I asked it to add another field to one of the tables. Remember, whilst I have Power BI and can add these fields into the tables that I have created for testing, ChatGPT is doing all of this in memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*Pzwdg75y7f7qK1ZbBFhWZA.png" /></figure><p>The first expression that it returned was exactly what I used in Power BI. Next, I wanted to test something a bit more complex than what we’ve been doing.</p><p>As you can see in the screenshot below, some of my KPIs’ reporting period spanned the entire Financial Year, whereas many are only for the quarter or a month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*WPuaDMOmXxVDq83Xe7UXNg.png" /></figure><p>What I want is to get the latest Actual Value for any KPI based on the Reporting Date To.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*xa1OlUCKMpqgdADzxKNyNQ.png" /></figure><p>Thus began my frustration with ChatGPT… If you want to skip this next part and go straight to the solution, go ahead and click <a href="#614d">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*wEdUOne8uxcpeNu7aeFxiw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*dkYRtEW3qehiY6lz7DTsSQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*d_jFOWuS_uNLLl0In6whZw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*iDeXLtfNVk89TCHKqP3SQw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*ZughUTiK6OulQ8t6bxVlxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*RyeD83YeE97ECr3f37PSMQ.png" /></figure><p>By this stage, my patience was wearing thin. So, I decided to give ChatGPT a hint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*0jWL542lpkMGGiUL_RcVeQ.png" /></figure><p>Not quite there yet…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*kq4DTdN173CU2Quz7qzG7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/561/1*RHP3QIHfC6one0wVXaginw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*o9NVlYuCxMp7eSfl70-qQw.png" /></figure><p>Ok. We’re starting to go in circle now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/567/1*5djxQVQtecmUEHtSC9tDrw.png" /></figure><p>At this stage, I’ve given up and simply gave ChatGPT the solution that I have written.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*q-vgGujOzlgEHRnkg3Fzhg.png" /></figure><p>You can see the differences below. Last Actual Value was what ChatGPT gave me, and Last Actual was the solution that I wrote and gave to ChatGPT above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*_xiR9qW9jZKWycgQ4qDTVQ.png" /></figure><p>As I have mentioned above, there can be many solutions to get the same result. So I thought I’ll give it another shot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*eF00mGNFVepp_XePvlbGtQ.png" /></figure><p>I must be a masochist…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*nsQJ2i6yBIuu3SbfknQJEg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*3BRryvCIAoTNN4-uJOgTDQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*hyBFw2B4ezu4dV3ps8yf2Q.gif" /></figure><p>Should we be worried that ChatGPT will take our jobs? Based on my experience above, not really.</p><p>Are there any advantages to ChatGPT? Despite the frustrating experience that I have had above, I have found that the explanations that it provided above when inspecting code was very helpful. It was able to clearly explained the code that I have written in a clear and concise manner and could actually be useful when explaining the code to others.</p><p>Next time, I will experiment with ChatGPT in other capacities to see if it can take over my other roles as a Business Analyst, a Project Manager, or as a Data Engineer. Given that it’s a text based language model AI, at least it won’t be taking over my role as a UX designer anytime soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2ca6fbd25bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with JSON in multiple database systems]]></title>
            <link>https://cathlynanderson.medium.com/working-with-json-in-multiple-database-systems-64bfd54523c8?source=rss-1c6c302799cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/64bfd54523c8</guid>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[mssql]]></category>
            <dc:creator><![CDATA[Cathlyn]]></dc:creator>
            <pubDate>Thu, 25 Nov 2021 03:03:17 GMT</pubDate>
            <atom:updated>2021-11-25T03:03:17.315Z</atom:updated>
            <content:encoded><![CDATA[<p>In my role as a BI Dev, I work with many different database systems as well as many different file types. Recently many of the applications that we integrate with to extract data have been storing their data in JSON format. The challenge for us then is to extract the required information for our reports/dashboards. Next, I will be showing you how to extract JSON contents from various database systems.</p><p>Given this sample file, we will be looking at how to extract the contents if this data was stored in MySQL, MSSQL, PostgreSQL and BigQuery.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e5a8953c7cef9c7011f805cc9d0e0de/href">https://medium.com/media/5e5a8953c7cef9c7011f805cc9d0e0de/href</a></iframe><h3>MySQL</h3><p>To get the orderer email address:</p><pre>select jsonCol -&gt;&gt; &#39;$.orderer.email&#39;</pre><p>To get the first customer email address (customers is an array here in case you didn’t realise):</p><pre>select jsonCol -&gt;&gt; &#39;$.customers[0].email&#39;</pre><p>To get the second customer email address:</p><pre>select jsonCol -&gt;&gt; &#39;$.customers[1].email&#39;</pre><p>To get the email addresses of ALL of the customers:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f07cd0250941421acb9bcefc053d9abc/href">https://medium.com/media/f07cd0250941421acb9bcefc053d9abc/href</a></iframe><h3>MSSQL</h3><p>To get the orderer email address:</p><pre>select json_value(jsonCol,&#39;$.orderer.email&#39;)</pre><p>To get the first customer email address (customers is an array here in case you didn’t realise):</p><pre>select json_value(jsonCol,&#39;$.customers[0].email&#39;)</pre><p>To get the second customer email address:</p><pre>select json_value(jsonCol,&#39;$.customers[1].email&#39;)</pre><h3>PostgreSQL</h3><p>To get the orderer email address:</p><pre>select jsonCol::json -&gt; &#39;orderer&#39; -&gt;&gt; &#39;email&#39;</pre><p>To get the first customer email address (customers is an array here in case you didn’t realise):</p><pre>select jsonCol::json -&gt; &#39;customers&#39; -&gt; 0 -&gt;&gt; &#39;email&#39;</pre><p>To get the second customer email address:</p><pre>select jsonCol::json -&gt; &#39;customers&#39; -&gt; 1 -&gt;&gt; &#39;email&#39;</pre><h3>BigQuery</h3><p>In BigQuery, JSON data may be stored in two ways:</p><ul><li><strong>In a column of type “RECORD”:</strong> This data type is specifically designed to store nested structure data (JSON) in BigQuery.</li><li><strong>In a column of type “STRING”:</strong> The JSON value is treated just like a normal string that happens to have JSON format. Let’s call this <strong>“stringified JSON”.</strong></li></ul><p>Each scenario needs to be handled differently as follow.</p><p>To get the orderer email address from a RECORD:</p><pre>select jsonCol.orderer.email</pre><p>To get the orderer email address from a stringified JSON:</p><pre>select JSON_EXTRACT(jsonCol, &#39;$.orderer.email&#39;)</pre><p>To get the first customer email address from customers JSON array from a RECORD:</p><pre>SELECT c.email<br>FROM tableWithJSONfield t<br>LEFT JOIN UNNEST(customers) as c<br>limit 1</pre><p>To get the first customer email address from customers JSON array from a stringified JSON:</p><pre>select JSON_EXTRACT(jsonCol, &#39;$.customers[0].email&#39;)</pre><p>To get the second customer email address from a RECORD:</p><pre>SELECT c.email<br>FROM tableWithJSONfield t<br>LEFT JOIN UNNEST(customers) as c<br>limit 1 offset 1</pre><p>To get the second customer email address from a stringified JSON:</p><pre>select JSON_EXTRACT(jsonCol, &#39;$.customers[1].email&#39;)</pre><p>To get the email address of ALL of the customers from a RECORD:</p><pre>SELECT c.email<br>FROM tableWithJSONfield t<br>LEFT JOIN UNNEST(customers) as c</pre><p>To get the email address of ALL of the customers from a stringified JSON:</p><pre>SELECT JSON_EXTRACT(c, &#39;$.email&#39;)<br>FROM tableWithJSONfield t<br>left join <strong>unnest</strong>(json_extract_array(jsonCol)) as j<br>left <strong>join</strong> <strong>unnest</strong>(json_extract_array(j, &#39;$.customers&#39;)) <strong>as</strong> c</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64bfd54523c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Preview Tableau Dashboard with specific parameters/filters set]]></title>
            <link>https://cathlynanderson.medium.com/preview-tableau-dashboard-with-specific-parameters-filters-set-7f165e94decb?source=rss-1c6c302799cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f165e94decb</guid>
            <category><![CDATA[tableau]]></category>
            <dc:creator><![CDATA[Cathlyn]]></dc:creator>
            <pubDate>Wed, 24 Nov 2021 13:19:46 GMT</pubDate>
            <atom:updated>2021-11-24T13:19:46.110Z</atom:updated>
            <content:encoded><![CDATA[<p>I use Tableau every day in my work as a BI developer. We have an automation system that we have built using Python that uses the Tableau REST API to export a (set of) views from (one or more) Tableau workbook(s) as a PDF. More often than not, we would be passing parameters/filters to these views to customise the data that is shown.</p><p>One of the challenges that we have is to try and replicate what a Dashboard/Sheet would look like when a parameter/filter is used if it was rendered by the Tableau Server, rather than viewing it in Tableau Desktop. We would often have a separate Dashboard in each Tableau workbook that we would set up specifically for changing Parameters and Filters. This can get tedious to switch back and forth between different Dashboards/Sheets. There is a little known trick that you can use to view how your Tableau Dashboard/Sheet would look like with all the parameters/filters set to specific values.</p><p><a href="http://tableau.ad.corelogic.asia/t/SiteName/views/WorkbookName/DashboardViewNameNoSpaceWithUnderscoreForSpecialCharacters?:embed=y&amp;Parameter+Name=Value&amp;Filter+Name=Value">http://tableau.server/t/SiteName/views/WorkbookName/DashboardViewNameNoSpaceWithUnderscoreForSpecialCharacters?:embed=y&amp;Parameter+Name=Value&amp;Filter+Name=Value</a></p><ul><li>Replace SiteName with the Tableau Site. Make sure there&#39;s no space</li><li>Replace WorkbookName with the name of the workbook with no space</li><li>Replace DashboardViewNameNoSpaceWithUnderscoreForSpecialCharacters with the name of the Dashboard or Sheet with no spaces but use _ in place of special characters</li><li>Add in any Parameters or Filters that you want to apply to the Dashboard/View after the ?:embed=y&amp; in the link. Use + for spaces in the Parameter/Filter Name and Value. Note that Parameters and Filters together with their values are case sensitive! Also, don’t have a Parameter with the same name as one of your Dimensions/Measures!</li></ul><p>In this way, to see what the Dashboard/Sheet will look like with an updated parameter/filter, you just change the corresponding value in the URL and hit Enter and you’re good to go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f165e94decb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Python String Repetition]]></title>
            <link>https://cathlynanderson.medium.com/python-string-repetition-542999cecf77?source=rss-1c6c302799cc------2</link>
            <guid isPermaLink="false">https://medium.com/p/542999cecf77</guid>
            <category><![CDATA[string-repetition]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Cathlyn]]></dc:creator>
            <pubDate>Wed, 24 Nov 2021 12:33:33 GMT</pubDate>
            <atom:updated>2021-11-24T12:45:06.809Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*p99fMEiURte7AsA2ZqpNmg.png" /><figcaption><a href="https://dariusforoux.com/repetition/">https://dariusforoux.com/repetition/</a></figcaption></figure><p>While I was working on one of my many hobby Python projects (I was attempting to scrape novels from some of my favourite online novel sites to convert them to epubs so I can read them offline when I go camping), I noticed that I was doing a lot of this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d5040c9662933c011c563a7820369701/href">https://medium.com/media/d5040c9662933c011c563a7820369701/href</a></iframe><p>There was a lot of copy and pasting going on for all of the | |-- for the print statements. I got about 6 levels deep and finally decided that enough was enough. I was going to simplify this process because frankly, my print statements were getting ridiculously long.</p><p>A quick search in my code snippets resulted in:</p><pre>def cprint(text, level: int):<br>    start = &#39;|   &#39;<br>    end = &#39;|-- &#39;<br><br>    print(f&quot;&quot;&quot;{start * (level - 1)}{end}{text}&quot;&quot;&quot;)</pre><p>The key is the last line which makes use of Python string repetition operator.</p><pre>print(f&quot;&quot;&quot;{start * (level - 1)}{end}{text}&quot;&quot;&quot;)</pre><p>Some of you may be wondering why I’m using f-string in the print statement instead of having the following?</p><pre>def cprint(text, level: int):<br>    start = &#39;|   &#39;<br>    end = &#39;|-- &#39;<br><br>    print(start * (level - 1), end, text)</pre><p>The reason for that is because when you have multiple items in a print statement that are comma-separated, python will add an extra space after each item, regardless of whether that item has a value or not. So if I was to call cprint(&#39;Some Text&#39;, 0) or cprint(&#39;Some Text&#39;, 1) the first option will print</p><pre>|-- Some Text</pre><p>whereas the second option will print (there is an extra space at the beginning if you can’t tell)</p><pre> |--  Some Text</pre><p>Here they are next to each other for comparison</p><pre>|-- Some Text<br> |--  Some Text</pre><p>Once I updated all my print statements, my code output now looks like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4aa4ecc13f63e3155b8d4efff961195b/href">https://medium.com/media/4aa4ecc13f63e3155b8d4efff961195b/href</a></iframe><p>That’s it! A simple and quick function to help prettify/simplify your print statements for better comments readability.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=542999cecf77" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>