[Tutor] Replace nth item with single value in each nested list

Alan Gauld alan.gauld at yahoo.co.uk
Thu May 14 19:23:14 EDT 2020


On 14/05/2020 23:01, EK Esawi via Tutor wrote:
>  I find it amusing and disappointing that some people seem to make judgment 
> without any proof about a posting as whether the question asked is a 
> homework or not-very disappointing indeed.

But there was evidence. An irrational desire to use an entirely
inappropriate programming idiom to solve a problem. That's a very
common sign that the question is a homework, as some teacher has
come up with a challenge to test her students on the use of
the current topic, whether its suitable in the real world or
not....

List comprehensions are deceptively concise, but in this case
it would result in extra memory usage and probably slower
performance than the simpler in-place solution.  Shorter code
is not necessarily the best code.

-- 
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