converting types

Fernando Pérez fperez528 at yahoo.com
Sun May 12 17:48:38 EDT 2002


ian wrote:

> but how do i convert an int into a string?
> the number variable errors
> 
> number = len(list)
> num = "list is " + number + " long"
> print num
> 

try also the easy form:

print 'list is',number,'long'

Print automatically puts spaces for you and 'magically' converts number to a 
string form. It's also more efficient than doing '+' on strings (for memory 
reasons you don't need to know right now).

Cheers,

f.



More information about the Python-list mailing list