[Tutor] if statement

Matthew Brunt mbrunt12 at gmail.com
Tue Jun 7 23:26:00 CEST 2011


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.

# Granted or Denied
# Demonstrates an else clause

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

password = input("Enter your password: ")

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

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


More information about the Tutor mailing list