You should create a counting variable. Whenever the user answers incorrectly, 
increment that variable by one. Starting with the fourth question and any 
question after, you should check the value of the variable to see if it is 
three or greater. If it is, then exit, if not, then continue. Check only 
beginning with the fourth question, because at the start of the first three 
questions, it would not be possible to already have three incorrect answers.


On Wednesday 07 December 2005 23:09, Trent Rigsbee wrote:
> Hi! My first "ever" program that I've created is a simple game called
> "State Capitals". It's straight forward; 5 simple questions about state
> capitals in a non-GUI format. Can someone look over my code and offer tips,
> suggestions, criticism? Also, I'd like to be able to end the program if the
> user misses 3 questions (i.e., kick them out after the 3rd wrong answer).
> How can I do this? Thanks!
>
>
> print "\nState Capitals! Answer a or b to the following questions.\n"
> question = raw_input("Question 1 - What is the capital of NC, a: Raleigh or
> b: Atlanta? ")
> if question == "a":
>       print "Yes\n"
> else:
>       print "WRONG\n"
>
> question = raw_input("Question 2 - What is the capital of SC, a: Greenville
> or b: Columbia? ")
> if question == "b":
>       print "Yes\n"
> else:
>       print "WRONG\n"
>
> question = raw_input("Question 3 - What is the capital of NY, a: Albany or
> b: Buffalo?")
> if question == "a":
>       print "Yes\n"
> else:
>       print "WRONG\n"
>
> question = raw_input("Question 4 - What is the capital of OH, a: Cleveland
> or b: Columbus? ")
> if question == "b":
>       print "Yes\n"
> else:
>       print "WRONG\n"
>
> question = raw_input("Question 5 - What is the capital of TX, a: Houston or
> b: Austin? ")
> if question == "b":
>       print "Yes\n"
> else:
>       print "WRONG\n"
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to