[mod_python] python print

Jonathan Gardner jgardner at jonathangardner.net
Wed Jun 11 11:17:54 EST 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wednesday 11 June 2003 10:48, tpc at csua.berkeley.edu wrote:
> On Wed, 11 Jun 2003, Jonathan Gardner wrote:
> > On Wednesday 11 June 2003 10:06, tpc at csua.berkeley.edu wrote:
> > >
> > > def convert(numbers):
> > >     w = []
> > >     for argument in numbers:
> > >         w.append([dict1[digit] for digit in argument])
> > > #        w += ''.join([dict1[digit] for digit in argument])
> > >     return w
> >
> > Change the line:
> > 	return w
> > to:
> > 	return "".join(w)
> >
>
> I tried something like that, and I just tried it with "".join and
> both times I got this error:
>
> TypeError: sequence item 0: expected string, list found
>

Oops. You'll also want to change:
	w.append([dict1[digit] for digit in argument])
to:
	[w.append(x) for x in [dict1[digit] for digit in argument]]
or:
	w.append(''.join([dict1[digit] for digit in argument]))

- -- 
Jonathan Gardner <jgardner at jonathangardner.net>
(was jgardn at alumni.washington.edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+53JSWgwF3QvpWNwRAm2yAJ404BiA7lGl/PU2NNJ5Lt4DSwaMyQCeJeqg
OB7LJEwIS23C9PdLCk+meb4=
=0I1k
-----END PGP SIGNATURE-----



More information about the Mod_python mailing list