79461340

Date: 2025-02-23 13:59:14
Score: 0.5
Natty:
Report link

why can't you use while loop to test validate input or not.

students = ["Julio","Jayden","Josh","John","Jamal"]

present = 0
absent = 0
for x in students:
    register=input(f"Is {x} present? ")
    while register not in ("yes", "no"):
        register = input(f"Is {x} present? ")
    if register == "yes":
        present += 1
    elif register == "no":
        absent += 1
print(f"{present} people are present")
print(f"{absent} people are absent")
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): why can't you use
  • Low reputation (0.5):
Posted by: Dayananda D R