473,569 Members | 2,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeating question with a loop

Thekid
145 New Member
How can I get this question to keep repeating until either a yes or no is given as an answer:

Expand|Select|Wrap|Line Numbers
  1. response = raw_input("Are you ready? ")
  2. if response.lower() == "yes":
  3.      print "Alrighty then, let's begin!"
  4. if response.lower() == "no":
  5.     print "Try again later when you are ready"
  6.  
Let's say you enter: maybe
I'd like the question to keep repeating. I tried making some 'for' loops but wasn't doing it right.
Jul 6 '09 #1
2 1937
bvdet
2,851 Recognized Expert Moderator Specialist
Encapsulate the input in a while loop. Use an if, elif, else block instead of multiple if statements.

Expand|Select|Wrap|Line Numbers
  1. while True:
  2.     response = raw_input("Are you ready? ")
  3.     if response.lower() == "yes":
  4.          print "Alrighty then, let's begin!"
  5.          break
  6.     elif response.lower() == "no":
  7.         print "Try again later when you are ready"
  8.         break
  9.     else:
  10.         print "Please enter 'Yes' or 'No' please."
Jul 6 '09 #2
Thekid
145 New Member
I see. I thought about the 'while' loop too but wasn't sure how to implement it. Thanks!
Jul 7 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2129
by: Developwebsites | last post by:
user enters non-repeating 100 numbers. how do i determine that numbs do not repeat? is this code correct? also, once a repeated number has been found, lets say I enter 345 twice, how do i break out of loop? could someone test this with random(1-1000). const int MAX=100; int Numb; bool exists;
3
8817
by: Jennie Friesen | last post by:
Hello-- I would like to display a different line of text (32 different messages) on refresh, BUT with no repeats. The script I am currently using is: <script language=javascript type=text/javascript> <!-- a = Math.floor(Math.random() * 32);
4
1951
by: NCrum | last post by:
I have a while loop which seems to run twice, I call one routine from another once the first loop is completed it returns to the calling routine (the line above) and runs again Calling routine() { ComboBox.FindStringExact(Textbox.text); // routine to be called runs from the //next line then returns to this line and
4
6109
by: Rob Johnson | last post by:
I have an ASP.Net calendar feature which allows users to add events and configure whether or not they repeat at various frequencies (i.e, daily, weekly, monthly, Sat/Sun, etc.). What I'm looking for is some C# code that will calculate a date of "Every Other Week" based on a starting date and ending date. Example: If a user enters an event...
1
1315
by: PaulF | last post by:
I am trying to do add a repeating XmlNode into and existing XML document and have had some problems. The base XML: <Property> <Premises> <Endorsement> <ShortWording/> <Wording/>
10
3394
by: lifity | last post by:
hi, i am stuck on part of my project and very new to VB. i had cut my picture into 6 equals part but need to display them randomly, without repeating the same part of the pic again, in random sequence. eg, pic1,pic2,pic3,pic4,pic5,pic6 to ==> pic3,pic2,pic6,pic1,pic5,pic4 below are part of my code Dim theImage(0 To 7) As Object ...
0
9328
by: Killer42 | last post by:
This is a simple VB6 function to generate random numbers in the specified range, without repeating any numbers. New, and only briefly tested. Use at your own risk. :) Option Explicit Private UsedNumber As New Collection Private Const MaxAttempts As Long = 150 Private Const Zero As Long = 0 Private Const One As Long = 1
1
1681
by: redskycorp | last post by:
I have repeating values in my combo box, i do want the values to repeat...any idea how to do that ? The reason is that i am taking the values from my database table "Incomplete" from the "Topic" column....The values repeats it self cause it shows all the values in the column including repeating ones....Anyone know what to do ? I have also included...
1
2205
by: Swede.Swede | last post by:
Hello! Customer wants a gridview displaying individuals who have taken part in courses. The gridview should be sorted by the name of the participant. If a person has taken part in several courses, the name should only be stated once. Example: Course Participant Date Skateboarding John Doe May 1st 2007 Sailing ...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.