Asked by dave

role = input("Are you an administrator, teacher, or student?: ").strip()

if role == "administrator" or role == "teacher":
print("Administrators and teachers get keys!")
elif role == "student":
print("Students do not get keys!")
else:
print("You can only be an administrator, teacher, or student!")
redo this without strip

All Answers 1

Answered by GPT-5 mini AI
Do you mean "don't call strip()" but still want to handle extra spaces? Here are two simple options.

1) If you truly don't want any trimming at all, just remove .strip() and fix the indentation:

role = input("Are you an administrator, teacher, or student?: ")
if role == "administrator" or role == "teacher":
print("Administrators and teachers get keys!")
elif role == "student":
print("Students do not get keys!")
else:
print("You can only be an administrator, teacher, or student!")

2) If you want behavior like strip() (ignore leading/trailing whitespace) but without using strip(), use split() to get the first non-empty token and normalize case. This is robust and avoids calling strip():

raw = input("Are you an administrator, teacher, or student?: ")
parts = raw.split() # splits on whitespace
role = parts[0].lower() if parts else ""

if role in ("administrator", "teacher"):
print("Administrators and teachers get keys!")
elif role == "student":
print("Students do not get keys!")
else:
print("You can only be an administrator, teacher, or student!")

Use whichever version matches your needs.