>> *************************************
> i want to write a function which will sort the sentence by the length of 
> each word in the sentece, short length first.please help.

Hi Nywbon,

First: please do not reply to the whole email digest.  The point of a 
reply is to continue a previous conversation.  Please be aware that not 
everyone has high-speed internet access: quoting the whole archive 
actually can strain some people's network bandwidth, if not their good 
humor and patience.

Since you are starting a new question, start a new email to create a new 
"thread" of conversation.


Second (and related to the first): please use a useful subject line.  It 
helps when people try to learn from the mailing list archives at:

     http://mail.python.org/pipermail/tutor/



Finally, to get back to your question:

> i want to write a function which will sort the sentence by the length of 
> each word in the sentece, short length first.please help.

This looks very much like a homework question.  We can not help you much 
with this.  The only thing we can really do is try to guide you 
indirectly.

Here are a few things you can do:

     1.  Write some concrete test examples of the problem statement and
         what you'd like to get out of it.

     2.  Show us some of the code that you've written so far, so we can at
         least point out areas of improvement.


For point one, let's take a totally different problem and demonstrate. 
Let's say we wanted to write a function to turn a number from 0-9 to a 
string of the Esperanto rendition.


If we wanted to write example cases, we'd imagine what calling this 
function for interesting inputs would look like.  For example:

     translate(0) --> "nul"
     translate(1) --> "unu"
     translate(2) --> "du"
     ...
     translate(9) --> "nau"

I use the arrow notation '-->' as an ad-hoc way of saying "I expect to get 
this value on the right hand side if everything is going well with my 
function".


Can you write examples of your own for your problem?
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to