Trying to get soemone to input a Password (hello) as an input and then getting a loop to a second part of the program where he/she inputs his/her name and then gets a response accordingly.
Not sure why this is not working but maybe someone else does.

let me know how you fixed the issue so i can learn from my mistakes.

print "Program 3 Loops and If Conditions"
#prints the title
print ("Author: Benoit Labelle")
#prints the author's name
print ("ID: 3065521")
#prints the authors id number
loop= 1
choice= 0
def enter_password():
       pwrd=raw_input("hello")
       wpass=raw_input("Password: ")
       return Password
def enter_name():
               cher=input("Can I get your authograph")
               madonna= input("Can I get your authograph")
               ben=input("What a great name!! ")
               benoit=input("What a great name!! ")
               choice = int(raw_input("Password ").strip())
               return 
while loop==1:
               print "Option 1: Enter your password"
               print "Option 2: Exit"
               choice = int(raw_input("Enter your option: ").strip())
               if choice ==1:
                   pwrd= input("Password")
                   if input is hello:
                       print "Welcome to the second part of the program"
                       loop==2
                   elif input is not hello:
                       print "Password"
               if choice== 2:
                   loop=0
print " Thank you come again"

while loop==2:
       choice = int(raw_input("What is your name: ").strip())
       if name==  Benoit:
             print "What a great name!!!"
       elif name == Madonna:
             print "Can I have your authograph?"
       elif name == Cher:
             print "May I have your authograph?"
       elif name != Benoit or Cher or Madona:
             print "what a nice name"

Recommended Answers

All 3 Replies

You never call the functions and you have many other problems like undefined variables and incorrect conditions.

Ignoring the fact that you define, but don't call, enter_password() and enter_name() functions ... at line 25, you get some input and assign it to variable pwrd, but at line 26, you're trying to check the value of variable input which you haven't assigned at all. And the way you test whether the user typed "hello" is to test whether the variable is equal to the string, not whether it's the same object as another undefined variable:

if pwrd == 'hello':

And at line 28, you're checking whether loop is equal to 2, not assigning the value to 2.

Hope this gets you started....

@raptr_dflo: Small correction: No input is a built in function, so actually it is defined, but of course not a string but a funcition.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.