Login and Password
Programming Basics · Python
TASK
Problem
Login and password are given on separate lines. Correct values are `admin` and `python123`. Print `ACCESS GRANTED` or `ACCESS DENIED`.
EXAMPLE
Example
admin python123
ACCESS GRANTED
LIMITS
Constraints
both strings are not empty
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `and` requires all combined conditions to be true. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `'ACCESS GRANTED'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['Both login and password must match.']
ANSWER
Solution
+
login = input()
password = input()
if login == 'admin' and password == 'python123':
print('ACCESS GRANTED')
else:
print('ACCESS DENIED')