-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()'関数を呼び出すことができます。 –