15Password Validation

Passwords are validated by comparing a user-provided value with a known value that’s stored. Either it’s correct or it’s not.

Create a simple program that validates user login credentials. The program must prompt the user for a username and password. The program should compare the password given by the user to a known password. If the password matches, the program should display “Welcome!” If it doesn’t match, the program should display “I don’t know you.”

Example Output

 
What is the password? 12345
 
I don't know you.

Or

 
What is the password? abc$123
 
Welcome!

Constraints

  • Use an if/else statement for this problem.

  • Make sure the program is case sensitive.

Challenges

  • Investigate how you can prevent the password from being displayed ...

Get Exercises for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.