Original Post
Ok, I'm trying to do something new to me, not sure if it's even possible going the route I'm going and I am having trouble finding any good search results for my attempt (so assuming I'm trying something wrong or taking it the wrong direction). In my program I have a nested while statement that asks for users to answer a yes/no question. If they answer yes, the loop breaks and the program continues, however, if they answer 'no' then it currently re-asks the same question. Here's the code: What I'd like to do is if the user types 'no' that the program asks a question, but it takes the questions from a pre-made dictionary or list. Then, every time the user types 'no' the program will take the next response from the list and print it. So, if I have a dictionary or list of 5 responses, each time the user types 'no' it will respond with the next phrase in the list. So far I've been trying to figure out how to do this using a dictionary to hold the phrases. response = {1:'phrase 1',2:'phrase 2',3:'phrase 3'} I am not sure if this is the right way to approach it, but I don't know how to handle getting each value (or returning the key as a value) one at a time and being able to print the result(well ok that's not true, I know how to get the value from a dictionary using the dictVar.get method). I don't want to have to write a new line for every response and make a ton of while loops. I figured there must be a way to have the code automatically pick the next phrase in some sort of loop using a dictionary or list. So, I don't want or need the answer to the question all coded out for me, I just need a hint at what direction I should be going. I'd like to figure some of this out on my own if possible. Should I be using a dictionary? A List? Should I write my own function to handle some of this? Thanks a bunch! [Edited by - Landshark on August 19, 2009 12:21:54 AM]
while 1:
ready = raw_input("How about now? (Yes/No) ")
if ready == 'yes':
print "It's about time! I was getting bored."
break