String question

Gaetan Corneau Gaetan_Corneau at baan.com
Wed Feb 16 21:12:35 CET 2000


Hi,

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

You are building a tuple (made of a string and an integer), not a list. 

Just use:

str = "n = " + str(n)

or str = "n = %d"%n

I used "str" instead of "string" because "string" is the name of a module.

Hope this helps,
______________________________________________________
   Gaetan Corneau
   Software Developer 
   Software Engineering Process Group
   BaaN  Supply Chain Solutions  
   http://www.baan.com
   E-mail: Gaetan_Corneau at baan.com                  
   Tel: (418) 266-8252         
______________________________________________________
"Profanity is the one language all programmers know best"





More information about the Python-list mailing list