0

develop a program which asks for a name and a password,and prints an acceptance message if the name is "aladdin" and the password is "sesane".the program should print a reject message in all other cases.this should be achived by combining the two tests into one using the "and"key word

3
Contributors
3
Replies
19
Views
3 Years
Discussion Span
Last Post by farmwife
Featured Replies
  • #! /usr/bin/env python def verify(username, password): if username == "aladdin" and password == "sesane": return True else: return False username = raw_input("Enter username: ") password = raw_input("Enter password: ") result = verify(username, password) if result: pass else: print("Invalid input.") Although it could probably be done much better by a more … Read More

1
#! /usr/bin/env python

def verify(username, password):
    if username == "aladdin" and password == "sesane":
        return True
    else:
        return False

username = raw_input("Enter username: ")
password = raw_input("Enter password: ")
result = verify(username, password)

if result:
    pass
else:
    print("Invalid input.")

Although it could probably be done much better by a more experienced programmer.

Edited by farmwife

0

vega, I think that was an exercise rather than practical application. It has zero practical value because the script is ascii! :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.