[Tutor] Programming Question

"Hugo González M." hugonz-lists at h-lab.net
Tue Sep 19 17:11:44 CEST 2006


> if number > 10:
>     print "That is an incorrect number.  Please try
> again."

Maybe you could do better if you check for all valid numbers first, and
finally if no valid number has been entered, then print an error
message, instead of checking for all possibilities of error. Hint: check
that you can use an "else" statement at the end.

> elif number == 9:
>     print "Nine"
> elif number == 10:
>     print "Ten"
> 
>         
> raw_input("\n\nPress the enter key to exit.")
> 
> How do I get it to work after an incorrect number is
> entered?  I am stuck on this and would appreciate and
> help or suggestions?

Well, there are structures that are useful for repeating stuff, have you
heard of "while" and "for"? Try to read up on how to use them, and you
can incorporate them in your program flow.


Have you seen Alan's tutorial? It's at:
http://www.freenetpages.co.uk/hp/alan.gauld/

Check the chapter on loops and the on on branching.

Hope that helps,

Hugo



More information about the Tutor mailing list