-2
# -*- coding: utf-8 -*-
#displays title

print ("          H___________________________________________   ")
print ("/========/| █░█ █▀▀█ █▀▀█ █░░ █▀▀█ █▀▀▄ █▀▀▄ \ ")
print ("|||||||||||-█̶▀̶▄̶ ̶█̶░̶░̶█̶ ̶█̶░̶░̶█̶ ̶█̶░̶░̶ ̶█̶▄̶▄̶█̶ ̶█̶░̶░̶█̶ ̶█̶░̶░̶█̶ -\ ")
print ("\========\|_▀̲░̲▀̲ ̲▀̲▀̲▀̲▀̲ ̲▀̲▀̲▀̲▀̲ ̲▀̲▀̲▀̲ ̲▀̲░̲░̲▀̲ ̲▀̲░̲░̲▀̲ ̲▀̲▀̲▀̲░̲ __\ ")
print ("          H ")
print ("          = ")

#intro
print ("Welcom to the land of kool")

#asks your name
name = input ("Can you tell me your name!")

#says hello
print ("Well hello",name,"!")

Error displayed:

NameError: name '______' is not defined
martineau
  • 119,623
  • 25
  • 170
  • 301

2 Answers2

3

Depending on the version of Python you are using you may need to use..

name = raw_input("Can you tell me your name!")

Check this out for reference. What's the difference between raw_input() and input() in python3.x?

Community
  • 1
  • 1
Noah Christopher
  • 166
  • 1
  • 13
1

TL;DR

Use raw_input() instead of input() in Python 2.x, because input() is "shorthand" for eval(raw_input)).


In Python 2.7, you need to use raw_input() instead of input(). raw_input() lets you read in user input as a string, while input() is "shorthand" for eval(raw_input()) which attempts to evaluate you user input as literal Python code

This is documented in the python 2.x documentation:

[input() is] Equivalent to eval(raw_input(prompt)).

This function does not catch user errors. If the input is not syntactically valid, a SyntaxError will be raised. Other exceptions may be raised if there is an error during evaluation.

If the readline module was loaded, then input() will use it to provide elaborate line editing and history features.

Consider using the raw_input() function for general input from users.

This however was later changed in Python 3.x. In Python 3.x raw_input() became input() and the old input(eval(raw_input())) was dropped. This is documented in What's new in Python 3:

PEP 3111: raw_input() was renamed to input(). That is, the new input() function reads a line from sys.stdin and returns it with the trailing newline stripped. It raises EOFError if the input is terminated prematurely. To get the old behavior of input(), use eval(input()).

(Emphasis mine)


So use raw_input() instead of input() in Python 2.x, because input() is "shorthand" for eval(raw_input)). eg. Change:

name = input ("Can you tell me your name!")

to

name = raw_input ("Can you tell me your name!")

Community
  • 1
  • 1
Christian Dean
  • 22,138
  • 7
  • 54
  • 87