#Python troubles in guidos gorgeous lasagna
60 messages ยท Page 1 of 1 (latest)
"""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 :
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.
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
Does the test fail? What is the test output?
Increase your chance of getting help and look like a pro by sharing codeblocks not images. For example, you can type the following. Note, the ``` must be on their own line.
```
for number in range(10):
total += number;
```
Discord will render that as so:
for number in range(10):
total += number;
Click here to learn more about codeblocks: https://exercism.org/docs/community/being-a-good-community-member/writing-support-requests and http://bit.ly/howto-ask
Woops. I missed the follow up post
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
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
so they have to be the same?
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
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```
I have no idea. Does it pass the tests now? Does the error go away?
The tests can tell you if it is better
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?```
yeah
This new error seems to be desciptive. Do you understand what it is complaining about?
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```
What does the error message say is the problem?
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()'.
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?```
Can you copy/paste the line of your code that defines the function preparation_time_in_minutes?
def Preparation_time_in_minutes():
Compare that closely to the error message. Do you see any differences?
progress!
Progress! One fix at a time ๐
ill do it later on, i gotta finish school (im homeschooled)
Good luck
@pulsar venture if you send the new things you are struggling with we can help you
Oh you just made a new post...
As @keen siren said, please provide details. We can't help without seeing what's going on.
i made a new post
You can close out this post ๐