NameError : name 'x' is not defined Python NameError

preview_player
Показать описание
The first video in the series dedicated to debugging various python errors. This video covers the NameError within python.
Рекомендации по теме
Комментарии
Автор

Welp, that didn't help. That just told me what a name error is. I want to know how to fix my name error. I HAVE defined my variable, but it still says it's not defined. Hmm. 

GretSeat
Автор

How to actually remove the Nameerror..
Could you post the solution to the error..like for the X+=1..How did you correct that

gokulyel
Автор

Love that he has 35K views and not one of those views had their question answered.

daryldyehouse
Автор

how do you define something then? like "multiply"

mikemkgta
Автор

As soon as i click IDLE, it pops up "IDLE's subprocess didn''t make a connection.

also Socket error

pls help

>>> 2+3
IDLE internal error in runcode()
Traceback (most recent call last):
File "D:\Python\lib\idlelib\rpc.py", line 236, in asyncqueue
if threading.current_thread() != self.sockthread:
AttributeError: 'MyRPCClient' object has no attribute 'sockthread'
>>>

-I am getting this error if I type just simple code, can u help to fix it

ARJUN-opdh
Автор

i dont get it
im having an issue with how to define something like multiply. im thinking it is app=Flask (_multiply_)

mikemkgta
Автор

first initialise the var like x=" ", then write the code x += 1....

navneetsingh
Автор

Hi, if you somehow didn't understand the tutorial, read this instead of sending toxic comments.
A NamError is something that occurs if python doesn't see where you defined your variable. For example, say your mom said to add a mango to a fruits list. What will you say? Logically, we'd make a new list but python isn't like this. You NEED to tell python what the value of x even is.
Example:

X = 1
Y = 2

print(X + Y)

Since you told python the values of x and y, it won't return an error! It's that simple!

standinginthelimelight
Автор

hello
please i have this error
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\User\Anaconda3\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "<ipython-input-12-2a0f40444ef6>", line 54, in <lambda>
command=(lambda e=ents: fetch(e)))
File "<ipython-input-12-2a0f40444ef6>", line 19, in fetch
clf.fit(self.Numerical, self.Catagorical)
NameError: name 'self' is not defined
can you help me to handle it

alameerahh
Автор

import numpy as np
def calc_euler_explicit(du, fu, delta_x, delta_t, gamma, c_offset):        nmax = len(fu)
        tt = gamma * delta_t / (delta_x * delta_x)
        su = c_offset * delta_t        for n in range(1, nmax-1):
                du[n] = tt * (fu[n+1] - 2.0 * fu[n] + fu[n-1]) + su
if__name__ == '__main__'
nmax = 15
delta_x = 1.0 / (nmax - 1)
fu = np.zeros(nmax)
du = np.zeros(nmax)  
for steps in range(1000):
        calc_euler_explicit(du, fu, delta_x, 1.0e-3, 1.0, 4.0)
        fu += du
        print("#  x    fu")
        for n, fu_n in enumerate(fu):
                print("%e %e" % (n * delta_x, fu_n))

visex.py

Dear, I am running the above code, but got the name error if name is not defined. I don't understand what is the problem?
looking forward for your guideline.

Thanks and Regards,
Ali

muhammadaliabid
Автор

Type 'x' that ah code thank you

cristianbatohinay
Автор

Thanks for not fixing the error Duh!
give me back my 5 mins of wasted time

paulaandrea
Автор

Excellent waste of time! You have this down to a science sir! Well done...Bravo! I learned nothing! Beautifully done!

johnhannon
Автор

Python is possibly the crappiest language I’ve ever used.

Madgamr