Python Forum
name is not defined error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: name is not defined error (/thread-9022.html)



name is not defined error - m123 - Mar-17-2018

hi

just started learning python.

i am trying to execute this code but unable to see the ouptut receiving error

an_letters = "aefhilmnorsxAEFHILMNORSX"
word = input("I will cheer for you! Enter a word: ")
times = int(input("Enthusiasm level (1-10): "))

i = 0
while i < len(word):
    char = word[i]
    if char in an_letters:
        print("Give me an " + char + "! " + char)
    else:
        print("Give me a  " + char + "! " + char)
    i += 1
print("What does that spell?")
for i in range(times):
    print(word, "!!!")
error IS
 runfile('C:/Users/s/.spyder/untitled1.py', wdir='C:/Users/solas/.spyder')

  File "C:\Users\sol\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
    execfile(filename, namespace)

  File "C:\Users\so\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/so/.spyder/untitled1.py", line 2, in <module>
    word = input("I will cheer for you! Enter a word: ")

  File "C:\Users\so\Anaconda2\lib\site-packages\ipykernel\ipkernel.py", line 176, in <lambda>
    builtin_mod.input = lambda prompt='': eval(self.raw_input(prompt))

  File "<string>", line 1, in <module>

NameError: name 'ROBOTS' is not defined
Any suggestion where to debug


RE: name is not defined error - buran - Mar-17-2018

the code is for python3 and you try to run it with python2
use python3.


RE: name is not defined error - m123 - Mar-18-2018

thankyou