Beginner | Think Python : Solution to Chapter 3 – Functions

Note : My solutions are independent of the solutions provided by the author. Just an info.


I tried to be a bit flexible with the solution by adding arguments, which allows variations in the number of columns and spacing between “+” and “-”

Difficulty: I tried to replicate the exact grid but the spacing was quite confusing for me. If you have an idea, do reference your solution. Thanks. 

Possible alternative

I was itching to use Python’s syntax for iterations since I do have a programming background knowledge, but I decided to stick with the timeline of the book. But once you complete the recursion & iteration chapter, I would recommend you redo this exercise by using your newly gained knowledge. Additionally, it would simply be another way to confirm your understanding on iterations.

Interesting point

The concept of passing a function as an argument

Solution

If you have any questions regarding the thought process, do not hesitate to ask. See you in the next chapter!

Links

Other related articles