Struggle to solve Guido's Gorgeous Lasagna - Task 4

Hello world!

I’m having quite the time trying to solve Task 4 in Guido’s Gorgeous Lasagna and can’t seem to figure out where I’m going wrong. My current iteration looks like the following:

def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
  
    total_preparation_time = number_of_layers * PREPARATION_TIME
    total_elapsed_time = EXPECTED_BAKE_TIME - elapsed_bake_time
    elapsed_time_in_minutes = total_preparation_time + total_elapsed_time

    return(elapsed_time_in_minutes)

And while I struggled with Tasks 2 & 3 as well, enough proverbial banging of my head against the wall (on constant revisiting of the hints) helped me to finally code the following:

EXPECTED_BAKE_TIME = 40

def bake_time_remaining(elapsed_bake_time):
    return(EXPECTED_BAKE_TIME - elapsed_bake_time)

def preparation_time_in_minutes(number_of_layers):
    PREPARATION_TIME = 2
    preparation_time_in_minutes = number_of_layers * PREPARATION_TIME
    return(preparation_time_in_minutes)

The reason I’m sharing everything is my assumption that all of it is required to successfully the test run.

What am I missing with all of this?

As an aside, am the only one to have difficulty interpreting what the instructions are asking of me? I’d like to consider myself able to visualize and extract concepts from text, yet these instructions seem unncessarily complex to me.

I think the confusion I had interpreting the instructions had me so flummoxed that I added more detail than was necessary. After taking a long walk to reset my brain, I took to pen & paper to conceptualize what was written in flow-chart form and discovered the error in my ways - my correction is as follows:

def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):

    total_preparation_time = number_of_layers * 2
    total_elapsed_time = total_preparation_time + elapsed_bake_time

    return(total_elapsed_time)```
1 Like

Note, return is not a function in Python; it shouldn’t be followed by ()

1 Like

Thank you for that! :smile:

Using return is new to me & made the false assumption it was a function similar to print. When I received the automated feedback after submission, this was called out and had me dig deeper into what it meant.

Code reviews are good for those discussions, too!