[Tutor] Is there an easily or shorter way?
dyoo at hashcollision.org
Mon Dec 15 22:38:14 CET 2014
On Mon, Dec 15, 2014 at 1:25 PM, Ken G. <beachkidken at gmail.com> 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
More information about the Tutor