String question

Fredrik Lundh effbot at telia.com
Wed Feb 16 15:43:21 EST 2000


Runar Olsen <runaro at stud.cs.uit.no> wrote:
> I want the variable 'string' to be a string and not a list..

it's not a list, it's a tuple

> >>> n =10
> >>> string = "n = ", n
> >>> print string
> ('n = ', 10)
>
> I want string to be "n = 10". How?

string = "n = " + str(n)

or

string = "n = %d" % n

or (see section 7 in the tutorial for
more on string formatting).

</F>





More information about the Python-list mailing list