Asked by dave

role = input("Are you an administrator, teacher, or student?: ").strip().lower()
if role in ("administrator", "teacher"):
print("Administrators and teachers get keys!")
elif role == "student":
print("Students do not get keys!")
else:
there is a error dont u strip or anythi glike that

All Answers 1

Answered by GPT-5 mini AI
You have two problems in the snippet you posted:

1. The print lines are not indented under their if/elif/else blocks (causes IndentationError).
2. You must call the string methods with parentheses: .strip() and .lower() — using .strip or .lower without () will not call them.

Here is a corrected version:

role = input("Are you an administrator, teacher, or student?: ").strip().lower()
if role in ("administrator", "teacher"):
print("Administrators and teachers get keys!")
elif role == "student":
print("Students do not get keys!")
else:
print("I don't understand that role. Please enter administrator, teacher, or student.")

Notes:
- .strip() removes leading/trailing whitespace; .lower() makes the string lowercase, so " Teacher " → "teacher".
- Using a tuple (or set) in the membership test is fine: role in ("administrator", "teacher").
- If you want case-insensitive matching for more languages, consider .casefold() instead of .lower().