how to get the ordinal number in list

Roy Smith roy at panix.com
Sun Aug 10 13:10:21 EDT 2014


In article <b5ac5b12-cda7-464e-9c14-63ef184a7a10 at googlegroups.com>,
 Rustom Mody <rustompmody at gmail.com> wrote:

> > They haven't figured out yet that the 
> > first step to solving a problem is to decide what algorithms you're 
> > going to use, and only then can you start translating that into code.  
> > They need to be led in small steps towards basic knowledge.
> [...]
> In my view this is starting from the wrong end.
> I do not need to know which kind of adder the hardware is implementing to
> use +, which sorting algorithm to use sort, etc.

Well, no, but if the problem is, "Find the 5 largest numbers in a list", 
you might start solving the problem by thinking, "OK, first I'm going to 
sort the list into descending order, then I'm going to take the first 
five items from that"(*)  Only then would you get down to "OK, how do I 
sort a list of numbers in this language", and "OK, how do I select the 
first five items from a list in this language".  That's what I mean by 
first you come up with an algorithm, then you implement it in code.

(*) Yes, I know, that's not the optimum way, but it's a reasonable first 
attempt.



More information about the Python-list mailing list