#python namerror help plz!!!!

56 messages · Page 1 of 1 (latest)

soft jasper
#

would be helpful if we can see what's going (NOT A PICTURE OR SCREENSHOT) with a codeblock. Also very likely that you don't understand how to define a variable correctly, read the instruction more carefully

ashen pawn
#

how do i do codeblock, again i am really new to python 😦

fading plaza
#

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.

cinder ferryBOT
fading plaza
#

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.

ashen pawn
#

print(LASAGNA)
#

did i do it right

fading plaza
#

That's right. Did you put both the error and your code in the same?

trail jacinth
#
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.

fading plaza
#

If you want the colors.

trail jacinth
#

source highlighting. It may not end up being colors depending on the reader. But it will end up being source highlighting, regardless.

ashen pawn
#

so what do i need to do fix the nameerror

fading plaza
#

We don't know what's wrong yet.

#

Please share your code.

ashen pawn
#

the entire code

trail jacinth
#

If that is your entire content of your source code, you will want to read the errors raised and provide what it needs.

fading plaza
#

The entire code.

trail jacinth
#

The error is stating that Lasagna is not defined. LASAGNA may be, but that is not Lasagna.

ashen pawn
#



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 
fading plaza
#

This is not your code.

#

Actually, it might be.

#

Is this what you are actually running?

trail jacinth
#

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.

ashen pawn
#

i trying figure out the lasagna excercise

fading plaza
#

Is this the code you have written into the editor?

trail jacinth
#

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.

ashen pawn
#

yea into editor not my own play ground

#

take out he lasagna= lasagna line

fading plaza
#
preparation_time_in_minutes(2)
4
#

Are you using the interactive editor? The one with >>>?

#

that starts when you type python on the commandline?

ashen pawn
#

yea

fading plaza
#

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.

ashen pawn
#

so do i need to do fix nameerror, do i give it variable but since there no integers added to the name lasagna

trail jacinth
#

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.

fading plaza
#

Oh, the editor is still there and you're supposed to use it.

trail jacinth
#

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.

fading plaza
#

i've noticed

trail jacinth
#

That said, it can work with a mentor available to help out someone that is totally new.

ashen pawn
#

so i ahve to find mentor to help me out

trail jacinth
#

It can help.

fading plaza
#

You probably need to study first. Check out youtube videos for the basics of python (which is a good language to start out with).

ashen pawn
#

okay thanks

trail jacinth
#

Also watch the Hello World Video as that can be immensely helpful for seeing things.

dim raven
#

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.