#python namerror help plz!!!!
56 messages · Page 1 of 1 (latest)
how do i do codeblock, again i am really new to python 😦
In Discord, you can type ```python on a starting line and ``` after your code to get a nicely colorized view of your code that keeps spaces.
That is specifically three backticks (`), python, new line, code, new line and three backticks.
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
We want to see your code, too.
Use backticks `
not apostrophes '
backticks are accent marks, it might be on a key that you need to press twice
Mine's next to backspace.
That's right. Did you put both the error and your code in the same?
print(LASAGNA)
This has the backticks and language on the first line (together with no space) and then the code you want to share, and then the closing backticks at the last line.
If you want the colors.
source highlighting. It may not end up being colors depending on the reader. But it will end up being source highlighting, regardless.
so what do i need to do fix the nameerror
the entire code
If that is your entire content of your source code, you will want to read the errors raised and provide what it needs.
The entire code.
The error is stating that Lasagna is not defined. LASAGNA may be, but that is not Lasagna.
LASAGNA = "Lasagna"
print(LASAGNA)
EXPECTED_BAKE_TIME = 40
lasagna = Lasagna()
print(EXPECTED_BAKE_TIME)
import lasagna
LASAGNA.EXPECTED_BAKE_TIME
40
def bake_time_remaining():
:param elapsed_bake_time: int - baking time already elapsed.
:return: int - remaining bake time (in minutes) derived from 'EXPECTED_BAKE_TIME'.
from lasagna import bake_time_remaining
bake_time_remaining(30)
10
from lasagna import preparation_time_in_minutes
preparation_time_in_minutes(2)
4
def elapsed_bake_time_in_minutes(number_of_layers, elapsed_bake_time):
:param number_of_layers: int - the number of layers in the lasagna.
:para elasped_bake_time: int - elapsed cooking time.
:return: int - total time elasped (in minutes) preparing and cooking.
from lasagna import elapsed_time_in_minutes
elasped_time_in_minutes (3, 20)
26
This is not your code.
Actually, it might be.
Is this what you are actually running?
Your error is coming form your own code, where you are asking to print the value but the value does not exist. Remove the print lines.
i trying figure out the lasagna excercise
Is this the code you have written into the editor?
And the line lasagna = Lasagna() is not likely wanted either. This is the specific statement that was causing the error though, as there was nothing with that name.
preparation_time_in_minutes(2)
4
Are you using the interactive editor? The one with >>>?
that starts when you type python on the commandline?
yea
do not use that for writing scripts. It's meant for trying out short, mostly one-line pieces of code, and it's hard to use for anything big.
You also can't save your scripts from it (I think).
no wait
sorry. I haven't looked at the Python stuff, but yeah, Guido's Lasagna stuff does use the interactive editor.
honestly, i don't see how this is newbie friendly at all.
so do i need to do fix nameerror, do i give it variable but since there no integers added to the name lasagna
If you have exercism command line interface installed locally you can submit a solution (even failing) and request mentoring. That can get both parties at the same point, seeing the same code.
Oh, the editor is still there and you're supposed to use it.
The site is not meant to be "newbie friendly" at the moment, it is for developers to practice, rather than to outright teach new programmers to program. It can be done, but the focus was not that when this was created. It is getting closer though.
i've noticed
That said, it can work with a mentor available to help out someone that is totally new.
so i ahve to find mentor to help me out
It can help.
You probably need to study first. Check out youtube videos for the basics of python (which is a good language to start out with).
okay thanks
Also watch the Hello World Video as that can be immensely helpful for seeing things.
@ashen pawn - There is a list of learning resources on the Python track, if you'd like to check some of those out: https://exercism.org/docs/tracks/python/learning
I can especially recommend "Automate the Boring Stuff". It is free online, and starts from scratch. The videos are outdated, but they still cover the basics really well.