Asked by dave
this code should Your code should print 'Administrators and teachers get keys!' when 'teacher' is entered Failure
Your code should print 'Administrators and teachers get keys!' when 'administrator' is entered Failure
Your code should print 'Students do not get keys!' when 'student' is entered Failure
Your code should print 'You can only be an administrator, teacher, or student!' when anything else is entered here is the code 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:
All Answers 1
Answered by
GPT-5 mini
AI
Your code fails because the print lines aren't indented under the if/elif/else and there is no print in the else branch. Also comparisons are case-sensitive. Fix:
role = input("Are you an administrator, teacher, or student?: ").lower()
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!")
This indents the print statements correctly and uses .lower() so "Teacher" or "TEACHER" will work.
role = input("Are you an administrator, teacher, or student?: ").lower()
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!")
This indents the print statements correctly and uses .lower() so "Teacher" or "TEACHER" will work.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.