Matthew Brunt wrote:
i'm very new to python (currently going through a python for beginners
book at work to pass the time), and i'm having trouble with an if
statement exercise.  basically, i'm creating a very simple password
program that displays "Access Granted" if the if statement is true.
the problem i'm having is that no matter what i set the password to,
it seems like it's ignoring the if statement (and failing to print
"Access Granted").  the code is copied below.  i'm pretty sure it's my
own programming ignorance, but i would greatly appreciate any
feedback.

More important than the exact solution to the problem is to learn how to solve this sort of problem:


password = input("Enter your password: ")
if password == "a":
   print("Access Granted")

If this is not doing what you expect, you should see what password actually is:

print(password)

It might also help to print the repr() of password, in case there are any unexpected spaces or other characters:

print(repr(password))

Of course, if you're getting an error instead, then you should read the error message, and look at the full traceback, and see what it says.



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to