Thanks for the enthusiasm on how input/raw_input() works - my original
intention was to ask a question on control flow so I didn't spend that
much time testing out this piece of input code besides typing. But I did
learn a lot. Thanks!
Gilbert
Jacob S. wrote:
I noticed that too, Liam.
b = input
I noticed that too, Liam.
b = input("Weather is really bad, still go out to jog? [y/n]") # Would
it kill you to have whitespace in a prompt?
should really be
b = raw_input("Weather is really bad, still go out to jog? [y/n]")
to get the effect he wants.
input() doesn't only take integers,
Kent Johnson wrote:
Bob Gailer wrote:
At 04:43 AM 1/29/2005, Liam Clarke wrote:
< erk, to the list, to the List!>
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to jog?[y/n]" )
if b == 'y':
go_jogging()
Anyone else notice
Bob Gailer wrote:
At 04:43 AM 1/29/2005, Liam Clarke wrote:
< erk, to the list, to the List!>
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to jog?[y/n]" )
if b == 'y':
go_jogging()
Anyone else notice that he's never gon
At 04:43 AM 1/29/2005, Liam Clarke wrote:
< erk, to the list, to the
List!>
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to
jog?[y/n]" )
if b == 'y':
go_jogging()
Anyone else notice that he's never gonna go jogging if
< erk, to the list, to the List!>
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to jog?[y/n]" )
if b == 'y':
go_jogging()
Anyone else notice that he's never gonna go jogging if the weather is bad?
Unless I've got input
> One way out of the top level is to call
> sys.exit(1)
Which works, but you need to import sys first.
Using
raise SystemExit
avoids the need for an import.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tu
SEveral solutions here.
The best is to restructure the code a little:
> def go_jogging():
> # go out and jog
> return
>
> if not bad_weather == 'y': # where is this initially set BTW?
go_jogging()
else
> # ask user only if weather is bad.
> b = input ( "Weather is really ba
One way out of the top level is to call
sys.exit(1)
-Original Message-
From: Orri Ganel [mailto:[EMAIL PROTECTED]
Sent: Friday, January 28, 2005 4:26 PM
To: Gilbert Tsang; Tutor@python.org
Subject: Re: [Tutor] Control flow
Gilbert Tsang wrote:
> Hi there, I have this lo
Gilbert Tsang wrote:
Hi there, I have this logic that I cannot wrap my mind it:
def go_jogging():
# go out and jog
return
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to jog?[y/n]" )
if b == 'y':
go_jogging()
e
Gilbert Tsang wrote:
Hi there, I have this logic that I cannot wrap my mind it:
def go_jogging():
# go out and jog
return
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to jog?[y/n]" )
if b == 'y':
go_jogging()
e
Hi there, I have this logic that I cannot wrap my mind it:
def go_jogging():
# go out and jog
return
if ( bad_weather =='y' ):
# ask user only if weather is bad.
b = input ( "Weather is really bad, still go out to jog?[y/n]" )
if b == 'y':
go_jogging()
else:
# program
12 matches
Mail list logo