String question

Mark Jackson mjackson at wc.eso.mc.xerox.com
Wed Feb 16 15:11:20 EST 2000


"Runar Olsen" <runaro at stud.cs.uit.no> writes:

> I want the variable 'string' to be a string and not a list..
> >>> n =10
> >>> string = "n = ", n
> >>> print string
> ('n = ', 10)

That's a tuple, not a list (but also not what you want).

> I want string to be "n = 10". How?

String concatenation, for which you want the string representation of
n.  One technique:

>>> n = 10    
>>> string = "n = " + `n`
>>> print string
n = 10

A few minutes with the tutorial would probably pay dividends. . .

-- 
Mark Jackson - http://www.alumni.caltech.edu/~mjackson
    Some years ago I was struck by the large number of falsehoods that
    I had accepted as true in my childhood, and by the highly doubtful
    nature of the whole edifice that I had subsequently based on them.
				- René Descartes





More information about the Python-list mailing list