对于以下程序,如果对任何问题的回答使用户没有资格投票,那么我如何让程序立即这么说而不问剩下的问题?
def main():
print("This program determines if a user is eligible to vote in the US\n")
q1 = str(input("Are you a US citizen? y/n: "))
q2 = int(input("What is your age?: "))
q3 = str(input("Do you meet your state's residency requirement? y/n: "))
if q1 == "n":
print("\nNot eligible to vote.")
elif q2 < 18:
print("\nNot eligible to vote.")
elif q3 == "n":
print("\nNot eligible to vote.")
else:
q1 == "y"
q2 >= 18
q3 == "y"
print("\nYou are eligible to vote!")
main()
临摹微笑
呼唤远方
猛跑小猪
相关分类