Я хотел бы иметь ответ «да» или «нет» Для каждого вопроса зарегистрироваться, повторяя то же самое для цикла, не перейдя на следующего человека, пока не будет введен «да» или «нет». < /p>
Код: Выделить всё
students = ["Julio","Jayden","Josh","John","Jamal"]
present = 0
absent = 0
for x in students:
register=input(f"Is {x} present? ")
if register == "yes":
present += 1
elif register == "no":
absent += 1
else:
print("invalid input")
# ^^^^^^ this is where I would want to make the code repeat the For loop again without moving onto the next person on the register
print(f"{present} people are present")
print(f"{absent} people are absent")
Подробнее здесь: https://stackoverflow.com/questions/794 ... ng-onto-th