use raw_input instead of input . as using input is unsafe as it evaluates your input as python command. for e,g. x = input("enter command") and u entered "1 + 2" as input., then it will evaluate 1+2 = 3 = x.
-nitin On Wed, Aug 18, 2010 at 12:45 PM, shane brennan <wiserwaylan...@gmail.com>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 > >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor