converting types

Chris Liechti cliechti at gmx.net
Sun May 12 17:13:50 EDT 2002


"ian" <iwaters at btclick.com> wrote in news:LIAD8.54124$7R.63494 at NewsReader:

> hi i know its a pain answering newbie questions
> that to you lot seem really simple
> 
> but how do i convert an int into a string?
> the number variable errors
> 
> number = len(list)
> num = "list is " + number + " long"
> print num

you can use "str()" or "repr()" or C like formating strings:
num = "list is %d long" % number

have you looked at the tutorial that was installed alonmg with the python 
docs? it's short and should help you to get the first hurdles.

crhis


-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list