Hi,

I would suggest appending the dice[roll] to a new list just after the print 
statement, then in the quit block order the list and then loop over it and 
print each entry.

Hope this helps,
Bodsda
Sent from my BlackBerry® wireless device

-----Original Message-----
From: Johnson Tran <aznj...@me.com>
Sender: tutor-bounces+bodsda=ubuntu....@python.org
Date: Wed, 11 May 2011 03:49:12 
To: <tutor@python.org>
Subject: [Tutor] Python program with multiple answers

Hi Guys, 

I've been working on a Python program where I create an 8 ball that will allow 
you to ask questions and will reply back with 20 possible answers. It will be 
continuous until the user says quit. My program works fine although I am trying 
to add something more to it, where when the user quits, it will present all the 
answers that the user got again and display them in alphabetical order...if 
anyone could point me in the right direction it'd be really helpful...my 
program so far is : (which works fine with no errros)



import random
dice = ("Without a doubt", "It is certain", "It is decidedly so","Yes", "For 
Sure", "No", "Dont count on it", "Try asking again","Reply hazy, try again", 
"Confucious says 'No'", "Better not tell you now","Cannot predict 
now","Concentrate and ask again","My reply is no","Outlook not so good","Very 
doubtful","Outlook is good","Most likely","As I see it, yes","I do not 
understand the question")
while True:
        choice = raw_input("Type 'ask' to ask a question. Type 'quit' to 
quit.\n")
        if choice == "ask":
                raw_input("Please enter your question:\n")
                roll = random.randint(0, 10)
                print dice[roll]
                raw_input()
        elif choice == "quit":
                True = 0
                raw_input()
        else:
                print "Error -- Try again\n"





Thanks,

JT

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to