beigginer: int+string
Chris Share
usenet at caesium.me.uk
Tue Jul 6 02:47:53 EDT 2004
On Tue, 06 Jul 2004 08:42:18 +0200, vertigo <none at microsoft.com> wrote:
> var1=0
> var2="text"
> var1=var1+2
>
> var3=var2+var1 ???
> i want to receive "text2" in var3, but i receive error can not add int
> to string. How can i do it ?
As the error message tells you, you can only add two variables of the
same type. Thus you need to change var1 to a string representation. One
way of doing this is:
var3 = var2 + str(var1)
chris
More information about the Python-list
mailing list