On Mon, Dec 15, 2014 at 1:25 PM, Ken G. <[email protected]> wrote:
> I am sure there is a better way to refine the following lines.
>
> Letting x equal a number from 1 to 28, go through 28 separate 'if'
> statements to print a resulting value that equaled the value of x.


Yes, the repetitive nature of those statements indicate that putting
the varying part in a data structure, like a list or dictionary, would
be greatly preferable.


As a side note: if we were to talk about how we'd do this in a
professional context, I think we'd recommend a library such as
"humanize", which has functions to go from numbers to human-friendly
string descriptions.

    https://pypi.python.org/pypi/humanize
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to