[Tutor] Hi there,

Alan Gauld alan.gauld at btinternet.com
Sat Jan 2 10:21:45 EST 2016


On 02/01/16 12:45, yehudak . wrote:


> I know the mathematical way to solve it (resulting in 24), but I want a
> Python solution.

Show us your code.

Usually "the mathematical way to do it" works in Python too.
Although there will likely be other ways that may sometimes
run faster or easier to code.

But until we see your code we can't comment on what you
are doing.

One way to try would be continually dividing by 10 until you
get a non-zero remainder. Count the number of divisions
necessary. Hint: The divmod() function may help here.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list