<?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>Forem: Maria</title>
    <description>The latest articles on Forem by Maria (@mariamodan).</description>
    <link>https://forem.com/mariamodan</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%2F171320%2F50d6c913-7dc1-4325-b98d-cfdf42e69ce5.jpg</url>
      <title>Forem: Maria</title>
      <link>https://forem.com/mariamodan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mariamodan"/>
    <language>en</language>
    <item>
      <title>How to reverse an integer in Python | LeetCode Practice</title>
      <dc:creator>Maria</dc:creator>
      <pubDate>Tue, 28 Jul 2020 14:21:08 +0000</pubDate>
      <link>https://forem.com/mariamodan/how-to-reverse-an-integer-in-python-leetcode-practice-218g</link>
      <guid>https://forem.com/mariamodan/how-to-reverse-an-integer-in-python-leetcode-practice-218g</guid>
      <description>&lt;p&gt;In this post I am going to go though my solution for this &lt;a href="https://leetcode.com/problems/reverse-integer/"&gt;exercise on LeetCode&lt;/a&gt; where you have to reverse an integer.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;123 -&amp;gt; 321&lt;/li&gt;
&lt;li&gt;-123 -&amp;gt; -321&lt;/li&gt;
&lt;li&gt;120 -&amp;gt; 21&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Constrains:&lt;br&gt;
If the integer is outside the range [−2**31,  2**31 − 1] return 0.&lt;/p&gt;

&lt;p&gt;Have a go at it and let's compare our solutions!&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;First I will post my solution then go though the reasoning behind it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:][::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'0'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;

            &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;

        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;

            &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'0'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;

            &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I've chosen to tackle this in 2 scenarios: when x &amp;lt; 0 and when x is &amp;gt;=0. Let's start with x &amp;lt; 0.&lt;/p&gt;

&lt;p&gt;First we turn x into a string, remove the '-' and reverse it. All of that is being taken care of by this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:][::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An example of what the above line does: -123 -&amp;gt; '-123' -&amp;gt; '123' -&amp;gt; '321'&lt;/p&gt;

&lt;p&gt;If the new string has '0' at the beginning, we use a while loop to remove all the zeros until we find a non-zero character:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'0'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we turn x back into a negative integer and check if it is within the size constraint. If it is we return x otherwise we return 0:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we will look at the case when x &amp;gt;= 0. &lt;/p&gt;

&lt;p&gt;If x &amp;lt;10 this means that is a single digit letter, it reversed would just be itself, so we return it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we follow the same logic as above. We turn it into a string and reverse it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We strip it of 0s if there are any at the beginning of the string:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;'0'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We turn it back into an integer and check against the constrains. If it doesn't meet the size requirements we return 0, otherwise return x:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;This was my solution, let me know if you had a different one!&lt;/p&gt;

&lt;p&gt;Also if you want you can follow me here or on Twitter :)&lt;/p&gt;

</description>
      <category>python</category>
      <category>tutorial</category>
      <category>codenewbie</category>
      <category>problemsolving</category>
    </item>
    <item>
      <title>Array Left Rotation | HackerRank practice</title>
      <dc:creator>Maria</dc:creator>
      <pubDate>Thu, 23 Jul 2020 11:18:23 +0000</pubDate>
      <link>https://forem.com/mariamodan/array-left-rotation-hackerrank-practice-41b2</link>
      <guid>https://forem.com/mariamodan/array-left-rotation-hackerrank-practice-41b2</guid>
      <description>&lt;p&gt;It's that sweet time in every developers career when you have to prepare for job interviews!&lt;/p&gt;

&lt;p&gt;To practice for upcoming interviews I decided to make my way though the problem solving challenges on HackerRank and share my solution here for further discussion.&lt;/p&gt;

&lt;p&gt;The first exercise in this series is &lt;a href="https://www.hackerrank.com/challenges/array-left-rotation/problem"&gt;Array Left Rotation&lt;/a&gt;, which I solved in JavaScript.&lt;/p&gt;

&lt;p&gt;In this problem you get the length of an array(&lt;em&gt;n&lt;/em&gt;), the number of left shifts(&lt;em&gt;d&lt;/em&gt;), and an array(&lt;em&gt;a&lt;/em&gt;). The goal is to performs &lt;em&gt;d&lt;/em&gt; rotations on the array, moving one element from the beginning to the end of the array.&lt;/p&gt;

&lt;p&gt;For example: if you have the array &lt;code&gt;[1, 2, 3, 4, 5]&lt;/code&gt; and &lt;em&gt;d&lt;/em&gt; is 2 then the algorithm should output &lt;code&gt;3 4 5 1 2&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Brute force approach
&lt;/h2&gt;

&lt;p&gt;This was my first solution to the problem: loop though the array &lt;em&gt;d&lt;/em&gt; times and each time move the first element to the end of the array.&lt;/p&gt;

&lt;p&gt;Remember: &lt;em&gt;a&lt;/em&gt; is the array and &lt;em&gt;d&lt;/em&gt; is the number of shifts to the left&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;elem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shift&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;elem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The slice solution
&lt;/h2&gt;

&lt;p&gt;If you look at the constrains listed in the HackerRank instructions you'll notice that &lt;em&gt;d&lt;/em&gt; is always smaller than &lt;em&gt;n&lt;/em&gt;, the array's length. This means we can use &lt;em&gt;slice()&lt;/em&gt; to slice off the first &lt;em&gt;d&lt;/em&gt; elements of the array and then concatenate it to the end of the array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;toShift&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;remaining&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;remaining&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;toShift&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;These are my 2 solutions! &lt;/p&gt;

&lt;p&gt;Please feel free to comment and add other solutions to this problem!&lt;/p&gt;

&lt;p&gt;Also if you want you can follow me here or on &lt;a href="https://twitter.com/maria_modan"&gt;Twitter&lt;/a&gt; :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>algorithms</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>3 cool things you can do with Python indexing</title>
      <dc:creator>Maria</dc:creator>
      <pubDate>Tue, 07 Jul 2020 18:22:01 +0000</pubDate>
      <link>https://forem.com/mariamodan/3-cool-things-you-can-do-with-python-indexing-49ei</link>
      <guid>https://forem.com/mariamodan/3-cool-things-you-can-do-with-python-indexing-49ei</guid>
      <description>&lt;p&gt;You can do so much with slicing and indexing in Python! Here are some of my favorite tricks:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Easily grab values from the end of a list
&lt;/h2&gt;

&lt;p&gt;If you have a list say &lt;code&gt;animals = ['cat', 'dog', 'squirrel','mouse','dolphin']&lt;/code&gt; and you want to grab the last value you could use &lt;code&gt;animals[len(animals - 1)]&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;However, Python offers you a way to easily access values from the other end of the list with &lt;strong&gt;negative indices&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;animals = ['cat', 'dog', 'squirrel','mouse','dolphin']

animals[-1] -&amp;gt; 'dolphin'
animals[-2] -&amp;gt; 'mouse'
animals[-5] -&amp;gt; 'cat'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Reverse a list
&lt;/h2&gt;

&lt;p&gt;If you want to reverse a list you could use a for loop or the built-in reversed() method...&lt;/p&gt;

&lt;p&gt;OR... you can use Python slicing and negative indices:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num_list = [4, 6, 3, 2, 1]
reversed_num_list = num_list[::-1]
print(reversed_num_list) -&amp;gt; [1,2,3,6,4]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One thing to remember is that slicing returns a new list, so using [::-1] will return a new list and it doesn't modify the original list. This also applies to the next trick!&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Skip every n-th element is a list
&lt;/h2&gt;

&lt;p&gt;If you have a list and you want to select every other element in it, Python easy way to do this is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
num_list[::2] -&amp;gt; [1, 3, 5, 7, 9]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's unpack what's going on in here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;':' tells Python to look at the whole list from start to finish&lt;/li&gt;
&lt;li&gt;':2' tells Python to skip every other element of the list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can customize this by providing the &lt;strong&gt;&lt;em&gt;start&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;the steps to skip&lt;/em&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num_list[3::2] -&amp;gt; [4, 6, 8]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can provide the &lt;strong&gt;&lt;em&gt;end&lt;/em&gt;&lt;/strong&gt; and the &lt;strong&gt;&lt;em&gt;steps to skip&lt;/em&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num_list[:6:2] -&amp;gt; [1, 3, 5]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or by providing the &lt;strong&gt;&lt;em&gt;start&lt;/em&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;em&gt;end&lt;/em&gt;&lt;/strong&gt; and the &lt;strong&gt;&lt;em&gt;steps to skip&lt;/em&gt;&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num_list[3:-2:2] -&amp;gt; [4,6]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even combine it with the previous tip and reverse your list whilst skipping elements!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;num_list[::-2] -&amp;gt; [9, 7, 5, 3, 1]
num_list[-2::-2] -&amp;gt; [8, 6, 4, 2]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Of course, this is just a short list of python’s capabilities, but these are the things that impressed me the most when I started learning.&lt;/p&gt;

&lt;p&gt;I encourage you to play around with the indices and slicing as this is the best way to get familiar and comfortable with them!&lt;/p&gt;




&lt;p&gt;Thanks for reading! If you want you can follow me here or on &lt;a href="https://twitter.com/maria_modan"&gt;Twitter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>What I Learned From Getting My First Developer Job</title>
      <dc:creator>Maria</dc:creator>
      <pubDate>Thu, 07 May 2020 17:51:38 +0000</pubDate>
      <link>https://forem.com/mariamodan/what-i-learned-from-getting-my-first-developer-job-3a7l</link>
      <guid>https://forem.com/mariamodan/what-i-learned-from-getting-my-first-developer-job-3a7l</guid>
      <description>&lt;p&gt;Six months ago I started searching for my first developer job. It took me about 6 weeks to get an offer, which I consider very lucky considering I was coming from a completely different background and taught myself to code (you can read more about coding journey &lt;a href="https://dev.to/mariamodan/from-studying-chinese-to-becoming-a-javascript-developer-4iej"&gt;here&lt;/a&gt;). It was a tumultuous time full of emotional ups and downs, and here is what I’ve learned from it:&lt;/p&gt;

&lt;h1&gt;
  
  
  1. It's a numbers game
&lt;/h1&gt;

&lt;p&gt;During my job hunting period I kept a trello board with the number of roles I applied to, as well as details for the roles I got interviews for. At the moment I accepted a job offer my numbers stood at this:&lt;/p&gt;

&lt;p&gt;Jobs applied to: 47&lt;br&gt;
Replies from recruiters: 6&lt;br&gt;
First rounds: 4&lt;br&gt;
Second rounds: 3&lt;br&gt;
Third rounds: 2&lt;br&gt;
Rejections: 1&lt;br&gt;
Offers: 1&lt;/p&gt;

&lt;p&gt;On average, I was hearing back from one role for each 9 roles I was applying to, but once I heard back I was quite likely to get offered a first round interview so APPLY APPLY APPLY! Out of the 47 jobs that I applied to I got to the final round for only 2, but I got an offer from a company that I liked and that’s all that matters. &lt;/p&gt;

&lt;p&gt;I suggest having a dedicated time in your day to send out applications as it can be quite time-consuming. I sent out a cover letter with every application, and, although I had a template and was only changing the introductory paragraph and a sentence here and there for every application, it still took me about 15-20 minutes to write one. &lt;/p&gt;

&lt;h1&gt;
  
  
  2. Know what you want (or better yet, what you definitely don’t want)
&lt;/h1&gt;

&lt;p&gt;It can be tempting when you are looking for your first developer job to want to cast the net as wide as possible and apply to every job you see. After all, if it’s a numbers game why not apply to as many jobs as possible?&lt;/p&gt;

&lt;p&gt;But that strategy is not as productive as you might think. Applying can take a lot of time especially if you're doing cover letters, and there are so many tech jobs out there(especially in a big city), that you can't possibly keep up with every new job that comes on the market. By applying to every role you see you might actually miss the application window for a role that would have really enjoyed. &lt;/p&gt;

&lt;p&gt;So hold your horses and ask yourself a very important question: Would you like working for that company/ in that role? And if the answer is not at least ‘yeah maybe’ then skip over that job posting. It’s normal to not know for sure from a job posting if you’d like working there, that’s what the interview process is for. However, if there are core responsibilities mentioned in the job description that you really don’t like and that would deter you from accepting an offer then don’t waste your time applying.&lt;/p&gt;

&lt;p&gt;I knew from my previous job that I don’t enjoy working very closely with external clients (I worked in marketing where I had multiple catch-up calls every day with clients and it was stressful!). So, for example, if I come across a job posting from companies where I’d be building websites for clients I knew to just skip over it.&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Focus your CV on your relevant experience even if it’s not employment
&lt;/h1&gt;

&lt;p&gt;Recruiters will only glance at your CV for about 10 seconds, so you want to make it easy for them to see your skills. &lt;/p&gt;

&lt;p&gt;When I was applying I didn’t have any professional dev experience, but I did build 2 full-stack apps as part of my portfolio. I made sure to talk about those projects at the top of my CV, detailing the technologies I used. I had completed a programming course where I worked within a team to build a website, so I made sure to include that in my experience as well.&lt;/p&gt;

&lt;p&gt;Here is the front page of the CV I used to apply:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnx5b9yq2bmteaj6bao2w.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fnx5b9yq2bmteaj6bao2w.JPG" alt="CV front page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Being involved in multiple hiring processes gives you leverage
&lt;/h1&gt;

&lt;p&gt;It’s a really good idea to not have all your eggs in just one basket. If you started the interview process with a company you like I would suggest it’s even more important to keep applying and interviewing at other places.&lt;/p&gt;

&lt;p&gt;And here’s why:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It will help with your nerves because your preferred company is now not your only shot at a dev job&lt;/li&gt;
&lt;li&gt;Being involved in different hiring processes gives you more interview experience and knowledge of the kind of questions asked&lt;/li&gt;
&lt;li&gt;Being involved in multiple interviewing processes, particularly in the later interview stages, can give you a lot of leverage to negotiate when you do receive an offer&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  5. Always negotiate
&lt;/h1&gt;

&lt;p&gt;Here you are, you applied, you did the take home test, you did the in person interview, and you’ve just received an offer! Finally you are about to enter the career you want and you just want to say yes on the spot in case they're about to change their minds.&lt;/p&gt;

&lt;p&gt;But don’t.&lt;/p&gt;

&lt;p&gt;The first offer companies make is rarely their most generous one. You worked hard  and you deserve to be compensated properly, so always negotiate!&lt;/p&gt;

&lt;p&gt;Before you head into the negotiation make sure to prepare:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Know what you want. Do your market research and know what number you’re aiming for, and also what’s the least you would settle for&lt;/li&gt;
&lt;li&gt;Prepare some bullet points on what your skills are &lt;/li&gt;
&lt;li&gt;If you’re involved in other hiring processes that are better paid, make sure to underline that&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is more or less what I said when I negotiated my pay:&lt;br&gt;
"At the moment I am in final round stages with companies who pay in the 35k-40k range. I believe this range matches my skills, experience and potential considering the tech stack I know and that I have one year of professional work experience dealing with clients and stakeholders. Would you be flexible to increase the salary to match that range?"&lt;/p&gt;

&lt;p&gt;And it worked, I got a 7k increase to their initial offer!&lt;/p&gt;

&lt;h4&gt;
  
  
  A note of portfolio websites:
&lt;/h4&gt;

&lt;p&gt;I did build one, but I am not sure anyone ever looked at it.&lt;/p&gt;

&lt;p&gt;I used a template to build it because design isn’t one of my strong points and I wanted to use the portfolio to illustrate my JavaScript projects. Putting together a portfolio website really helped in getting me to frame my ‘tell me about yourself’ story, as well as talk about my projects. &lt;/p&gt;

&lt;p&gt;So even though I haven't directly used mine I would encourage you to build a portfolio website.&lt;/p&gt;

</description>
      <category>career</category>
    </item>
    <item>
      <title>Python List Methods: .append() Vs .extend()</title>
      <dc:creator>Maria</dc:creator>
      <pubDate>Fri, 17 Apr 2020 16:09:35 +0000</pubDate>
      <link>https://forem.com/mariamodan/python-list-methods-append-vs-extend-1i1f</link>
      <guid>https://forem.com/mariamodan/python-list-methods-append-vs-extend-1i1f</guid>
      <description>&lt;p&gt;Append and extend are both Python methods used to add elements at the end of lists, but how do they differ and which one should you use?&lt;/p&gt;

&lt;h2&gt;
  
  
  .append()
&lt;/h2&gt;

&lt;p&gt;Append takes in one argument and adds it to the end of the list.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'chocolate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'chips'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'almonds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'apples'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print out &lt;code&gt;['chocolate', 'chips', 'almonds', 'apples']&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Let’s say you have a lot of extra snacks you want to add to your list, you could do it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'apples'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'blueberries'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'oranges'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what happens if you don't want to keep typing the same command over and over again and try to append all the extra snacks at once? If we do this using append we will get an undesirable outcome:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'chocolate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'chips'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'almonds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;'apples'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'blueberries'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'oranges'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will print out &lt;code&gt;['chocolate', 'chips', 'almonds', ['apples', 'blueberries', 'oranges']]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;It added the elements to the list but it added the whole list of new snacks at the same index. &lt;code&gt;print(snacks_for_later[4])&lt;/code&gt; will result in &lt;code&gt;['apples', 'blueberries', 'oranges']&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can sort this using .extend()&lt;/p&gt;

&lt;h2&gt;
  
  
  .extend()
&lt;/h2&gt;

&lt;p&gt;Extends allows you to add multiple elements to a list at once.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'chocolate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'chips'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'almonds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt; &lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s"&gt;'apples'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'blueberries'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;'oranges'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Will print out &lt;code&gt;['chocolate', 'chips', 'almonds', 'apples', 'blueberries','oranges']&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Under the hood, extend iterates over its argument, adding the argument's elements to the initial list.&lt;/p&gt;

&lt;h4&gt;
  
  
  A note of caution:
&lt;/h4&gt;

&lt;p&gt;If you pass a string to extend it will iterate over the characters in the string and add them to the list separately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'chocolate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'chips'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'almonds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'apples'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Will print out &lt;code&gt;['chocolate', 'chips', 'almonds', 'a','p','p','l','e','s']&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A similar thing would happen if you pass in a dictionary:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'chocolate'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'chips'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'almonds'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;extend&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;'snack1'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;'apples'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'snack2'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s"&gt;'blueberries'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;snacks_for_later&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Will print out &lt;code&gt;['chocolate', 'chips', 'almonds', 'snack1', snack2']&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Both append and extend only take in one argument, trying to pass them more than one will result in a TypeError&lt;/li&gt;
&lt;li&gt;When you use append, the list's length grows by one. If you pass it a list or dictionary then the last element of the list will be that list or dictionary&lt;/li&gt;
&lt;li&gt;When you use extend, the list's length grows by the number of elements of extend's argument. If you pass it a list with length 3, all 3 elements will get added to the list separately and the list length will grow by 3.&lt;/li&gt;
&lt;li&gt;If you pass a string as extend's arguments every character from that string will get added to the list separately&lt;/li&gt;
&lt;li&gt;If you pass a dictionary to extend, it will add to the list just the keys of the dictionary&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>beginners</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>From Studying Chinese To Becoming A JavaScript Developer</title>
      <dc:creator>Maria</dc:creator>
      <pubDate>Tue, 14 Apr 2020 11:05:01 +0000</pubDate>
      <link>https://forem.com/mariamodan/from-studying-chinese-to-becoming-a-javascript-developer-4iej</link>
      <guid>https://forem.com/mariamodan/from-studying-chinese-to-becoming-a-javascript-developer-4iej</guid>
      <description>&lt;p&gt;Hey there, I’m a JavaScript developer from London who, like many nowadays, followed a non traditional path to get into tech. It took me a little over a year to make the transition and I wanted to share my journey, hoping it helps if you’re also considering making a switch in your career.&lt;/p&gt;

&lt;p&gt;First let me give you some background, I wasn’t completely new to programming when I started pursuing a career in tech. During high school we had Computer Science classes where we learned basics such as for loops, if statements and functions. So, even though when I went back to programming I hadn’t done anything technical in over 4 years, I’m pretty sure that having a vague memory of the basics helped shave off months of study time. Funnily enough, when I was in high school I enjoyed that class so much that I considered doing a degree in Computer Science, but ultimately 17 year old me decided that spending all your day typing code on a computer wasn’t the career for her.&lt;/p&gt;

&lt;p&gt;Instead, I went on to get a degree in Contemporary Chinese Studies, and, although I really enjoyed my uni experience, I found myself, like many new grads, not really knowing what to do next.&lt;/p&gt;

&lt;p&gt;In August 2018, after graduation, I moved out to London and got a job in digital marketing. The job had some repetitive tasks, which I found out you could automate with scripts in JavaScript. Motivated to make my work a bit easier, I took a JavaScript basics course on &lt;a href="https://www.codecademy.com/learn/introduction-to-javascript"&gt;CodeCademy&lt;/a&gt; and that is how programming reentered my life. What followed were three learning stages that landed me where I am today:&lt;/p&gt;

&lt;h3&gt;
  
  
  1.Dabbling in it (November 2018 - February 2019)
&lt;/h3&gt;

&lt;p&gt;For the next couple of months the most interesting bits of my job were playing around with JavaScript. My skills were quite basic at that point, but nonetheless it was exciting to get the computer to do what I wanted with just some lines of code! &lt;/p&gt;

&lt;p&gt;During this time I happened to make a lot of friends who worked as software developers.They helped shatter the belief I held for a long time: that all a developer does is mechanically type code 24/7. I began to understand that a developer’s job is much more creative and engaging than I had previously thought.  About 4 months after moving to London I had a job that wasn’t fulfilling, a JavaScript course under my belt, and friends who were really enjoying their jobs as software developers, who got to work on interesting problems, and were also getting paid a lot more than me. The math wasn’t hard to do, I decided to join them and started looking into ways I could learn and enter the industry.&lt;/p&gt;

&lt;p&gt;I knew I lacked Computer Science knowledge and wanted to start with the basics, so I enrolled in Harvard’s &lt;a href="https://online-learning.harvard.edu/course/cs50-introduction-computer-science"&gt;CS50: Introduction to Computer Science&lt;/a&gt; online course. The C practice problems seemed like an impossible mountain to climb and got me questioning life a number of times, but I was able to push through with the help of my CS friends.&lt;/p&gt;

&lt;p&gt;At the beginning of 2019 I decided that the best way to get into tech was by doing a masters in Computer Science. After all, what better way to prove to prospective employers that I was a good candidate than to have a degree in the subject? Looking back, my application was quite weak as at that time I still wasn’t sure what I was doing or what my learning trajectory was. Not knowing when I’d hear back from the universities I decided to not waste time and continue studying by myself.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.Serious study (February-July 2019)
&lt;/h3&gt;

&lt;p&gt;My commitment to daily practice started when I reached the web development section of the CS50 course, finally a subject where code wasn’t looking as cryptic as C!  I wanted to get a deeper understanding into this topic and that’s when I turned to &lt;a href="https://www.freecodecamp.org/"&gt;FreeCodeCamp&lt;/a&gt;. The concepts were broken down into small exercises which made it possible to do little bits at a time, soon I was doing one hour of programming before or after work learning HTML and CSS. &lt;/p&gt;

&lt;p&gt;In April I got the amazing opportunity to take part in the Python for Web Development course delivered by &lt;a href="https://www.codefirstgirls.org.uk/"&gt;Code First: Girls&lt;/a&gt; in partnership with Bank of America. Not only did I get to meet some amazing people in the industry, but I also worked in a team for the first time to deliver a project (ours was a quiz which matched the user with a hidden bar in London and it won second place :D)&lt;/p&gt;

&lt;p&gt;At this time I was beginning to understand just how many fields there are in tech, and I knew I had to focus on one to structure my studying and maximize my chances of getting a job. I chose to pursue Front-End because it seemed the most straight-forward way to get into the industry for people coming from other disciplines (for example, bootcamps would mostly focus on the Front End) and also the interview process seemed more junior-friendly (usually no whiteboarding interviews).&lt;/p&gt;

&lt;p&gt;After the 8 week course ended I continued studying in my free time.I finished the JavaScript section on FreeCodeCamp, started building small projects, and attended coding coaching meet-ups. I was getting more and more committed to this path.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.All in (July 2019 - November 2019)
&lt;/h3&gt;

&lt;p&gt;Around June I was beginning to suspect that I didn’t get into the CS Master, as I still hadn’t heard anything back. I started to look for other routes that could take me towards my goal and identified 3:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Continue studying on the side of my main job&lt;/li&gt;
&lt;li&gt;Attend a bootcamp&lt;/li&gt;
&lt;li&gt;Quit work and study full-time by myself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first option wasn’t attractive at all because I was already frustrated with giving my most productive hours to a job I didn’t enjoy. I was also growing frustrated with the pace at which I was going, I wanted to move faster towards my goal of becoming a software developer.&lt;/p&gt;

&lt;p&gt;Next on was the bootcamp option. I’ve heard mixed reviews about bootcamps but one aspect stuck out to me: the price. There is no getting around the fact that they are quite expensive (not as expensive as a master’s but a degree also comes with a university’s prestige). In London the cheapest bootcamp was £8,000 with others running way above that, not to mention the living cost that I’d have to cover while attending the bootcamp and until I’ve found a job.&lt;/p&gt;

&lt;p&gt;Considering that most learning resources were available online for free or relatively cheap, I ended up going for the third option. My lease was expiring in July so I handed in my resignation and moved back home to Romania to study full time (I know this option is not available to everyone which is why I am so grateful to my parents for allowing me to move back in and covering my living expenses while I pursued my studies).&lt;/p&gt;

&lt;p&gt;I wanted to have structure in my self study (my personal bootcamp as I called it) so I sat down and set some goals with a self-taught developer I met through Code First: Girls looking at what skills I’d need for an entry level job. Then I looked at bootcamp curriculums to make sure my study plan didn’t have any obvious gaps and was good to go!&lt;/p&gt;

&lt;p&gt;During the next months I was studying 5-6 hours/day. It was definitely a challenging time, I’d say the hardest part was not having direct access to someone who could answer my questions (where I lived there were no coaching meetups like in London). Twitter proved extremely helpful in this regard, not only did I get to connect with a lot of developers going though the same journey, but it also provided a platform where I could get answers on my coding questions.&lt;/p&gt;

&lt;p&gt;In August I finally got my rejection from the universities, but since I was on my own path now I didn’t mind that much.&lt;/p&gt;

&lt;p&gt;During these months I:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Learned React&lt;/li&gt;
&lt;li&gt;Completed a full stack development course on Udemy&lt;/li&gt;
&lt;li&gt;Built my portfolio site (which I’m not sure anyone ever looked at)&lt;/li&gt;
&lt;li&gt;Built 2 full stack projects with React and Node.js: a card memory game and a task management app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In November I started applying to Front-End roles, even though I was feeling completely unprepared for it. To my surprise, the response was much better than I had expected. I was applying to roles in London, where ,I’m suspecting, because of the high demand for dev roles they were more open to people coming from non-traditional backgrounds. I interviewed at 3 companies (thank God all the technical questions I got were JavaScript and not data structures and algorithms) and got one offer which I accepted!&lt;/p&gt;

&lt;p&gt;And there you have it, It was a long process but one that was definitely worth it. I still have a lot to learn but I am sure I am on the right track.&lt;/p&gt;

</description>
      <category>career</category>
      <category>beginners</category>
      <category>newbie</category>
      <category>motivation</category>
    </item>
  </channel>
</rss>
