Python Forum

Full Version: name is not defined error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
the code is for python3 and you try to run it with python2
use python3.
thankyou