[Tutor] My First Program
Trent Rigsbee
sweetdaddysiki at hotmail.com
Thu Dec 8 05:09:20 CET 2005
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"
More information about the Tutor
mailing list