Simple script problem with dynamic text

Probably I overlook something really trivial, but here goes:

The task is to display a text with a number. Ie “n apples”, where n should be a certain integer-20. In my code (Blender 2.57) this is:

text = str(carrier-20)+" apples"
settext.value = text
cont.activate(settext)

Where settext is a property actuator that sets the text displayed, carrier is the integer that should be displayed. When running, the text string becomes something like this:

[2 + [Extra characters after expression]]

(when carrier was 22 for example)
instead of

2 apples

I just cannot figure out what is going wrong. Any help, pretty please?

I suggest to use the new text function in 2.5.
create a simple textobject(no Plane with font texture!)


def addText(cont, content, pos,col,life):
    own = cont.owner
    text = sce.addObject("Text", own, life)
    text.worldPosition = pos
    text.color = col
    text.text = content
    return text

text = addText(cont, "Textcontent", (-29,21,0), (0,1,0,1), life)

it is simple to use, the only bad thing ist the scaling of the text, this can pixelate it to unreadable…

I guess your property that you want to set is a int.
Simply change it to a string.

BTW. The property actuator can do this without python script too:

value: (carrier-20)+" apples"