An earlier version of this article was posted here, on Medium.
When I decided earlier this year that I was going to blog about my life, I was oblivious to how I might approach it. With that blissful ignorance I began to flesh out a draft of my approach to the task and it resulted in the article above.
Since then, I’ve read more blogs on tech topics, taking notes along the way and decided to switch up the format. I’m going to try and make a weekly series of blog posts about my challenges learning to code and how I overcome them.
That’s from the Udacity CS101 course, lesson number 5 which I encountered at the start of June. If you’re like me, you think it sounds simple enough…in application to solving a problem, boy, was I wrong.
The lesson (for me) gave adequate but not great detail about the syntax/components of a for loop and no support for problem solving techniques. So when the course asked you to create a function with a loop to give the factorial of a number input
(n), I was puzzled to say the least.
I was left to “poke and hope” at the code for the problem. I could fathom that we needed to increment the
(n) value down by 1 and reinsert it back into the function I declared but no matter how I wrote it, this happened:
I was at a loss. Worse yet, I was beginning to question if I was cut out for programming. The fabled impostor syndrome I read about had begun to set in.
I decided to blame the language and move on with other areas of my studies.
Three weeks passed and…nothing.
I had progressed with Codecademy and was enjoying it, but admittedly it was mostly HTML/CSS. I always had that problem in the back of my mind, though.
At this point I had invested many hours into Codecademy and I knew the structure of their lessons and exercises would be detailed enough that I might get somewhere.
I was half right.
After taking the loop lesson and passing their basic exercise, I tried to program a factorial function and lo and behold! …
I got stuck.🤦🏻♂️
Now, it’s important that I mention my pride in my ability to learn. I never struggled in school. In fact, often I excelled with ease. Therefore, I was stubbornly insistent on not “cheating” and looking up the answer. I would learn this was misguided.
Besides, I didn’t really know who to ask for help. Or, how to word the question.
Here is what they should look like solved proper:
For Python, I remembered after seeing the solution video, that indentation and white space are critical to the syntax of your code and how it executes. So, with
return result right under the
while loop’s procedural code block it was returning the input. By simply aligning the
return result with the
while statement itself we get the proper result.
console.log(result) was placed. When it is before the second to last closing curly bracket (
}) then the loops code block includes it as an iterative step in the procedure. Outside of that second to last curly bracket and it returns just the final result!
The response was fast and friendly. I thought, “No trolls? Is this really the internet?”
But user [at]domhabersack was helpful in making a suggestion without exactly giving the answer away.
I applied that suggestion and the code worked! I was even able to refine it from my initial solution to something that I thought was more readable/logical.
The imposter syndrome had subsided and I found my “groove” again.
I’m not sure if there will always be some wholesome meta lesson to wrap up my posts but I think today there is:
- It’s okay to not know the answer.
- It’s expected that you’ll need help when you’re starting out. So just ask!
Maybe I got lucky, but I’m holding out that this wasn’t a one-off. Faith in humanity restored.
Thanks for reading! If you liked this article…
Feel free to comment, share any open source projects or other suggestions at the bottom or just drop a line to share your thoughts!
If you want to reach me via e-mail and separate from this article, I’m open for freelance opportunities or just a friendly chat on your tech interests, click the button 😎