[Tutor] way of dictating leading zeros

Alan Gauld alan.gauld at btinternet.com
Mon Mar 16 10:38:01 CET 2009


"Patrick" <optomatic at rogers.com> wrote

> Is there an easy way to dictate how many digits a number will occupy
> that also allows for leading zeros?

Andre showed you the way to do this using "String Formatting".
Search for that phrase in the docs for al lot more info.

If you are considering using Python v3 then that style is deprecated 
and
you may want to use the new String Formatter object. See the Python 3
string docs for more on that.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk 




More information about the Tutor mailing list