PROBLEM 71
Medium

User Access Level

Programming Basics · Python

</>
STATUS Not solved

TASK

Problem

#71

Given role `guest`, `user`, `moderator`, or `admin`, print access level 0,1,2,3.

EXAMPLE

Example

Input
moderator
Output
2

LIMITS

Constraints

role is always valid
📖
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`. `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 `0` shows how this idea is applied to the task data.

💡
NEED HELP? Hints
+

['Map each string to a number.']

ANSWER Solution
+
r = input()
if r == 'guest':
    print(0)
elif r == 'user':
    print(1)
elif r == 'moderator':
    print(2)
else:
    print(3)