[Tutor] sort problem

Alan Gauld alan.gauld at btinternet.com
Wed Sep 8 19:40:29 CEST 2010

"Roelof Wobben" <rwobben at hotmail.com> wrote

> > Carefully read the documentation for str.join: 
> > http://docs.python.org/library/stdtypes.html#str.join
> >
> >How does it work, what does it return, etc. Then fix the 
> >corresponding line in your code.
> str.join(iterable)¶
>It puts all the elements of iterable into one string named str.

Thats not what the documentation says...

> So it returns a string.

Thats true.,

When trying to understand how a function works, or debug these kinds 
errors use the >>> prompt to experiment. It's the definitive way of 
seeing what
Python will do.

For example try:

>>> "123".join([5,6,7])

Can you see what Python has done?

Use the >>> prompt it is one of the most powerful tools you have.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list