Lasagna exercise

I tried my best to solve this exercise and I find the overall experience so confusing.
I’d like to implement the todo’s step by step and get feedback on it. It appears not possible, the editor evaluates the whole code and gives me errors all the time.

https://exercism.org/tracks/python/exercises/guidos-gorgeous-lasagna

I can’t ask for mentorship before having posted a full solution.
It’s too hard for me to start straight with a function. Too much for my second exercise.
I’m not new to python, but I’ve never seen anything like this.
Hope this helps.

I can’t see your solution, so here are some general tips:

Perhaps consider using a constant with a meaningful name for 2 instead of it being a magic number.

Python doesn’t have real constants, but the uppercase naming convention is used to indicate they should not be reassigned.

Perhaps consider calling preparation_time_in_minutes in elapsed_time_in_minutes to keep the code DRY.

The TODO comments could have the TODO: removed at a minimum, or be completely deleted.

Consider using parameter names that are more meaningful than, say, t or l.

How to write docstrings can be found here.

It’s good to know the distinctions between comments and docstrings.

Also, to learn more about test-driven development on Python, you can see here. Basically, ignore the errors for functions you haven’t implemented yet and check that the tests pass for the function(s) you have implemented. It’s an iterative process.

You can though, but by submitting the exercise from the command line, using the exercism command line tool.

Developing from the comfort of your own system has merit, as well as better visibility to what is happening, so I highly suggest it if spending time with the language.

Hi @RobertCodeGit

I’m sorry that this exercise is a struggle. It is indeed a lot to be hit with after Hello World. We’ve tried our best to be detailed, but if you haven’t had practice writing functions or dealing with test failure, it is a steep learning curve.

Here are a few suggestions (your milage may vary for these):

The Python docs have a tutorial section that goes over everything from using the REPL, to how to work with numbers, strings, functions and more. It may or may not be a good entry into functions for you.

These tutorials/courses may also be of help: Learn Python (dot) org || 4-hour Scrimba Course || Educative: Functions in Python || python basics (dot) org: functions

One strategy I used when getting used to using the return statement in functions was to use the print() statement instead to check that the output of my function was what what I intended it to be.

While the exercism platform is not a good environment for doing that because of the way we run & report test results, the pythontutor website will allow you to write a small set of functions with print statements and walk through them to see their results. Here is a link to the first of the Lasagna functions with inputs. You can step through and see what is going on, and when you are happy with the results, you can change print to return for use with the exercism tests.

One other thing you can do locally on your own programming environment is to comment out any test in the test file that you are not currently working on. That way, you only get failures for the specific task you have written code for.

Hope some of that helps.

1 Like