nameerror

How to fix NameError in input() function in Python 3.x?

How to fix NameError in input() function in Python 3.x? Question: I am currently running Python 3.7.2 on Windows 10. I am trying to use this code print(‘Hello’+input()) but it’s not working. When I input a name, say, John, after Python has printed ‘Hello’, it gives me the following error message: Traceback (most recent call …

Total answers: 1

NameError: name 'x' is not defined(Python 3.7)

NameError: name 'x' is not defined(Python 3.7) Question: I am new to python , I am learning "if and else" condition in python 3.7. So the issue is , when I type my this code def age_group(user_age): x = int(input("Enter your age :")) return x if x < 150 : print(age_group(x)) else : print("Either he …

Total answers: 1

Python NameError: name 'include' is not defined

Python NameError: name 'include' is not defined Question: I’m currently developing a website with the framework Django (I’m very beginner), but I have a problem with Python: since I have created my templates, I can’t run server anymore for this reason (the stack trace points to a line in file urls.py): <stacktrace> … path(‘apppath/’, include(‘myapp.urls’)), …

Total answers: 1

NameError : name "a" is not defined

NameError : name "a" is not defined Question: I have made a simple calculator.py program in Python, but the program fails with NameError: "a" is not defined. How can I fix it? import math def control(a, x, y, z, k): return { ‘ADDITION’: addition(x, y), ‘SUBTRACTION’: subtraction(x, y), ‘MULTIPLICATION’: multiplication(x, y), ‘DIVISION’: division(x, y), ‘MOD’: …

Total answers: 2

function name is undefined in python class

function name is undefined in python class Question: I am relatively new to python and i am experiencing some issues with namespacing. class a: def abc(self): print "haha" def test(self): abc() b = a() b.test() #throws an error of abc is not defined. cannot explain why is this so Asked By: aceminer || Source Answers: …

Total answers: 2

Python NameError: name 'self' is not defined Why?

Python NameError: name 'self' is not defined Why? Question: At the top: import pygame, sys from pygame.sprite import Sprite from pygame.locals import * pygame.init() Part not working: class DetectionBox(Sprite): def __init__(self): Sprite.__init__(self) self.img = pygame.Surface([SCREEN_WIDTH, SCREEN_HEIGHT/4], SRCALPHA, 32).convert_alpha() self.pos = (0, SCREEN_HEIGHT – (SCREEN_HEIGHT/4)*3) DETECT_BOX = DetectionBox() Error: NameError: name ‘self’ is not defined Someone …

Total answers: 1

NameError: global name 'unicode' is not defined – in Python 3

NameError: global name 'unicode' is not defined – in Python 3 Question: I am trying to use a Python package called bidi. In a module in this package (algorithm.py) there are some lines that give me error, although it is part of the package. Here are the lines: # utf-8 ? we need unicode if …

Total answers: 7

python: NameError:global name '…‘ is not defined

python: NameError:global name '…‘ is not defined Question: in my code, I have: class A: def a(): …… def b(): a() …… b() Then the compiler will say “NameError: global name a() is not defined.” If I pull all the stuffs out of the class A, it would be no problem, but how can I …

Total answers: 1

Python NameError: name is not defined

Python NameError: name is not defined Question: I have a python script and I am receiving the following error: Traceback (most recent call last): File “C:UsersTimDesktoppop-erptest.py”, line 1, in <module> s = Something() NameError: name ‘Something’ is not defined Here is the code that causes the problem: s = Something() s.out() class Something: def out(): …

Total answers: 3

Python: NameError: global name 'foobar' is not defined

Python: NameError: global name 'foobar' is not defined Question: I have written the following class: class myClass(object): def __init__(self): pass def foo(self, arg1, arg2): pp = foobar(self, arg1, arg2) if pp: return 42 else return -666 def foobar(self, arg1, arg2): if arg1 == arg2: return 42 else: return None The logic is nonsensical – ignore …

Total answers: 1