[Tutor] Else command

Alan Gauld alan.gauld at blueyonder.co.uk
Sat Aug 7 00:52:27 CEST 2004



> What command would I use and in what order to make it respond to
everything
> but what I defined a certain variable as? For example I tell it that
hi=
> "Hello" and then I want it so it says "what?" for everything else

if not hi == "hello":
   print 'what?'

Is that what you mean?

An alternative way is to use the not-equal operator:

if hi != "hello":
   print "what?"


HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list