473,507 Members | 6,295 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 1923
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
2119
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...
3
8808
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...
4
1946
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()...
4
6103
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...
1
1310
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
3391
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...
0
9299
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...
1
1678
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"...
1
2197
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...
0
7220
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,...
0
7105
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...
0
7371
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...
0
7479
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...
1
5037
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...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.