#Python troubles in guidos gorgeous lasagna

60 messages ยท Page 1 of 1 (latest)

pulsar venture
#

i just updated my code, i noticed a couple errors, heres the updated version,'

#
    """Calculate the rest of the baking time"""    
   elapsed_bake_time = 40
def bake_time_remaining():
    bake_time_remaining = 30
   bake_time_remaining = EXPECTED_BAKE_TIME - bake_time_remaining
  return bake_time_remaining
def Preparation_time_in_minutes():
    """how many layers?"""
   Preparation_time_in_minutes(number_of_layers = 2)
  number_of_layers * 2
 return number_of_layers
def elapsed_time_in_minutes():
    """number of layers + elapsed bake time."""
   elapsed_time_in_minutes(number_of_layers, elapsed_bake_time)
  elapsed_time_in_minutes = number_of_layers + elapsed_bake_time
 from lasagna import elapsed_time_in_minutes
elapsed_time_in_minutes(3, 20)
26```
#

i also got these errors :

exotic wolf
#

Good morning/afternoon/evening/night!

If you enclose the code in three backticks (usually next to 1 on the keyboard) It will format the code

which can be easier to read
and debug for anyone taking a look```

Additionally including the failing tests and their errors (also preferably in that code block), that can help a lot with identifying what's actually going on. 

theres a couple of things im noticing that seem weird on first view, though im unsure how much of it is just the copy/paste acting up vs being an actual coding issue, namely things like `elapsed_bake_time` being defined twice and some weird indentations that could be causing you issues.
pulsar venture
#
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
.usr.local.lib.python3.11.site-packages._pytest.pathlib.py:533: in import_path
    importlib.import_module(module_name)
.usr.local.lib.python3.11.importlib.__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
.usr.local.lib.python3.11.site-packages._pytest.assertion.rewrite.py:168: in exec_module
    exec(co, module.__dict__)
.mnt.exercism-iteration.lasagna_test.py:8: in <module>
    from lasagna import (EXPECTED_BAKE_TIME,
E     File ".mnt.exercism-iteration.lasagna.py", line 3
E       elapsed_bake_time = 40
E                             ^
E   IndentationError: unindent does not match any outer indentation level```
#

heres it actually put in a code block firstly

#
    """Calculate the rest of the baking time"""
   elapsed_bake_time = 40
def bake_time_remaining():
    bake_time_remaining = 30
   bake_time_remaining = EXPECTED_BAKE_TIME - bake_time_remaining
  return bake_time_remaining
def Preparation_time_in_minutes():
    """how many layers?"""
   Preparation_time_in_minutes(number_of_layers = 2)
  number_of_layers * 2
 return number_of_layers
def elapsed_time_in_minutes():
    """number of layers + elapsed bake time."""
   elapsed_time_in_minutes(number_of_layers, elapsed_bake_time)
  elapsed_time_in_minutes = number_of_layers + elapsed_bake_time
 from lasagna import elapsed_time_in_minutes
elapsed_time_in_minutes(3, 20)
26```
#

im brand new so

#

please hurry i gotta leave soon

ruby sandal
#

Does the test fail? What is the test output?

winged wagonBOT
pulsar venture
#

yes

#

the errors up there

ruby sandal
#

Woops. I missed the follow up post

pulsar venture
#
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
.usr.local.lib.python3.11.site-packages._pytest.pathlib.py:533: in import_path
    importlib.import_module(module_name)
.usr.local.lib.python3.11.importlib.__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
.usr.local.lib.python3.11.site-packages._pytest.assertion.rewrite.py:168: in exec_module
    exec(co, module.__dict__)
.mnt.exercism-iteration.lasagna_test.py:8: in <module>
    from lasagna import (EXPECTED_BAKE_TIME,
E     File ".mnt.exercism-iteration.lasagna.py", line 3
E       elapsed_bake_time = 40
E                             ^
E   IndentationError: unindent does not match any outer indentation level```
#

those are the errors

ruby sandal
#

The indentation of line 3 does not match the expected indentation, i.e. the indentation of the block it is in -- which is set by the indentation of the prior line.

#

That is, line 2 and 3 have different indentations

pulsar venture
#

so they have to be the same?

ruby sandal
#

Yes

#

Unless there is an if or def or something which is expected to be followed by a new block

#

Two statements part of the same block level need to be indented the same

pulsar venture
#

what about now, is my codee better?

#
    """Calculate the rest of the baking time"""
    elapsed_bake_time = 40
def bake_time_remaining():
    bake_time_remaining = 30
    bake_time_remaining = elapsed_bake_time - bake_time_remaining
    return bake_time_remaining
def Preparation_time_in_minutes():
    """how many layers?"""
    Preparation_time_in_minutes(number_of_layers = 2)
    number_of_layers * 2
    return number_of_layers
def elapsed_time_in_minutes():
    """number of layers + elapsed bake time."""
    elapsed_time_in_minutes(number_of_layers, elapsed_bake_time)
    elapsed_time_in_minutes = number_of_layers + elapsed_bake_time
    from lasagna import elapsed_time_in_minutes
    elapsed_time_in_minutes(3, 20)
    26```
ruby sandal
#

I have no idea. Does it pass the tests now? Does the error go away?

#

The tests can tell you if it is better

pulsar venture
#

now i got this error

#

MISSING FUNCTION --> In your 'lasagna.py' file, we can not find or import the function named 'preparation_time_in_minutes()'. 
Did you misname or forget to define it?```
ruby sandal
#

Sounds like you managed to fix the indentation error!

#

So that's promising.

pulsar venture
#

yeah

ruby sandal
#

This new error seems to be desciptive. Do you understand what it is complaining about?

pulsar venture
#

not really, this is my code now

#
    """Calculate the rest of the baking time"""
    EXPECTED_BAKE_TIME = 40
def bake_time_remaining():
    bake_time_remaining = 30
    bake_time_remaining = EXPECTED_BAKE_TIME - bake_time_remaining
    return bake_time_remaining
def Preparation_time_in_minutes():
    """how many layers?"""
    Preparation_time_in_minutes(number_of_layers = 2)
    number_of_layers * 2
    return number_of_layers
def elapsed_time_in_minutes():
    """number of layers + elapsed bake time."""
    elapsed_time_in_minutes(number_of_layers, EXPECTED_BAKE_TIME)
    elapsed_time_in_minutes = number_of_layers + EXPECTED_BAKE_TIME
    from lasagna import EXPECTED_BAKE_TIME
    elapsed_time_in_minutes(3, 20)
    26```
ruby sandal
#

What does the error message say is the problem?

pulsar venture
#

that they cant import preparationtimeinminutes

#

do i have to import it?

ruby sandal
#

Did you misname or forget to define it?

#

Is that function in your code?

pulsar venture
#

its defined

#

its imported

ruby sandal
#

Can you copy/paste the line of your code that defines the function?

#

In your 'lasagna.py' file, we can not find or import the function named 'preparation_time_in_minutes()'.

pulsar venture
#

but i got this error ```ImportError:

MISSING FUNCTION --> In your 'lasagna.py' file, we can not find or import the function named 'preparation_time_in_minutes()'.
Did you misname or forget to define it?```

ruby sandal
#

Can you copy/paste the line of your code that defines the function preparation_time_in_minutes?

pulsar venture
#

def Preparation_time_in_minutes():

ruby sandal
#

Compare that closely to the error message. Do you see any differences?

pulsar venture
#

i got rid of the capital p

#

it worked, but it says 0 / 5 tasks completed ๐Ÿ˜ฆ

ruby sandal
#

Progress! One fix at a time ๐Ÿ˜‰

pulsar venture
#

ill do it later on, i gotta finish school (im homeschooled)

ruby sandal
#

Good luck

pulsar venture
#

hey, still cant figure these bugs out

#

@ruby sandal could you help me?

keen siren
#

@pulsar venture if you send the new things you are struggling with we can help you

#

Oh you just made a new post...

ruby sandal
pulsar venture
#

i made a new post

ruby sandal
#

You can close out this post ๐Ÿ˜‰