[Tutor] boolean raw_input

Michael Lange klappnase at freenet.de
Thu Aug 19 00:18:03 CEST 2004


On Wed, 18 Aug 2004 23:07:45 +0100
"Bernard Lebel" <python at bernardlebel.com> wrote:

> Hello,
> 
> Recently I saw on this list a bit of code that used a boolean expression
> inside a raw_input call, and of course realized after I deleted the email
> that I actually need that. If I remember correctly, it was something like:
> 
> raw_input( 'text', [y/n] )
> 
> However trying this didn't work, and I looked through the docs without
> success. Can anyone tell me the how-to?
> 

Bernard,

maybe you mean something like this:

answer = raw_input('Do you want me to print "hello"? [y/n]')
if answer in ('Y', 'y'):
    print 'hello'

Michael


More information about the Tutor mailing list