how to finish a while loop...
- From: icarus <rsarpi@xxxxxxxxx>
- Date: Tue, 19 Feb 2008 17:00:41 -0800 (PST)
Hi all, i'm new to python. Learning on my own how to ask a user to
finish a loop or not.
For some reason, it behaves as infinite loop although I changed its
condition. Please tell me what I'm doing wrong. Thanks in advance.
condition = True
while ( condition ):
try:
integer_one = int ( raw_input( "Please enter an
integer: " ) )
integer_two = int ( raw_input( "Please enter the
second integer: " ) )
division = integer_one / integer_two
except( ZeroDivisionError ):
print "\nDivision by zero detected"
except( ValueError ):
print "\nYou didn't enter an integer"
else:
print "The result is", division
answer = raw_input("Do you want to try again (yes or
no)? ")
if answer == 'yes':
condition
elif answer == 'no':
condition = False
print "Good bye, you don't want to continue"
.
- Follow-Ups:
- Re: how to finish a while loop...
- From: Bruno Desthuilliers
- Re: how to finish a while loop...
- From: Paul Rubin
- Re: how to finish a while loop...
- From: richie
- Re: how to finish a while loop...
- From: Guilherme Polo
- Re: how to finish a while loop...
- Prev by Date: Re: The big shots
- Next by Date: Re: Threads vs. continuations
- Previous by thread: Adding more warnings
- Next by thread: Re: how to finish a while loop...
- Index(es):
Relevant Pages
|