On 18/08/2010 09:15, shane brennan wrote:
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
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
input() [1] expects a valid Python expression as input as it gets
evaluated and is not technically safe.
raw_input() [2] is what you should be using instead.
[1] http://docs.python.org/library/functions.html#input
[2] http://docs.python.org/library/functions.html#raw_input
Hope that helps. Welcome to the list and enjoy your stay.
--
Kind Regards,
Christian Witts
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor