[Tutor] Getting confusing NameError

shane brennan wiserwaylander at gmail.com
Wed Aug 18 09:15:40 CEST 2010


Hi Tutors

This is my first mail to this list so firstly thank you for reading and
apologies in advance for any noob mistakes i may have inadvertantly made:).
Ive only started learning python as my first programming language and its
all going well so far, working my way through a couple of books one of which
is programming python: for absolute beginners by Michael Dawson

In one of the code samples he supplies while doing loops ( namely if and
else loops) im getting a NameError i dont understand and cannot find any
help anywhere about it. here is the code he supplied and the error im
getting

# Password
# Demonstrates the if statement

print("Welcome to System Security Inc.")
print("-- where security is our middle name\n")

password = input("Enter your password: ")

if password == "secret":
    print("Access Granted")

input("\n\nPress the enter key to exit.")


and the traceback error im getting

Traceback (most recent call last):
  File "G:\Programming\Python\programming python\chapter3\password.py", line
7,
in <module>
    password = input("Enter your password: ")
  File "<string>", line 1, in <module>
NameError: name 'secret' is not defined


I know this is probably very simple but for some reason i cannot get my head
around it.

thank you for any help in advance

shane
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100818/42dd7d3c/attachment.html>


More information about the Tutor mailing list