-1
나는 if else
진술을 사용하여 학교에 간단한 프로그램을 작성하려고합니다. 프로그램을 종료하지 않고 기준에 맞지 않으면 첫 번째 질문 이후에 스크립트를 중단하고 싶습니다. 여기에 지금까지 무엇을 가지고 :프로그램을 중지하지만 종료하지 않습니까?
age=int(input("How old are you? ")) #add a line to skip the other two inputs if not old enough
#registered = input("Are you a registered voter? yes/no ").lower()[:1]
#precinct = input("Are you in your registered precinct? yes/no ").lower()[:1]
if age >= 18:
print("You are old enough to vote. ") #Determines if old enough to vote.
else:
print("You are not old enough to vote. ")
registered = input("Are you a registered voter? yes/no ").lower()[:1]
if registered == 'y':
print("You are registered to vote. ")
else:
print("Do you have documentation showing your permanent address? ")
precinct = input("Are you in your registered precinct? yes/no ").lower()[:1]
if precinct == 'y':
print("You are in your precinct and can vote. ")
else:
print("You must be in your precinct to be able to vote. ")
if age >= 18 and registered == 'y' and precinct == 'y':
print("Congratulations you may vote! ")
else:
print("Sorry you may not vote. ")
"중지"란 무엇입니까? 보통 우리가 멈추는 프로그램에 대해 말하면 프로그램이 종료되었음을 의미합니다. –
프로그램을 종료하려면 원하는 곳 어디에서나'quit()'함수를 호출하면됩니다. –