by Guest » Mon Sep 26, 2005 12:49 pm
ewww
the easiest way by far to concatenate strings in python is with the "+" operator.
For example, lets say you want to load a random sound from a list of sounds called sound1.mp3, sound2.mp3, and sound3.mp3. Yes, you could put these in a dictionary, or a list, or you could just do this:
num = randint(1,3)
mySound = loader.loadSfx("sound" + str(num) )
This concatenates num (which is typecast as a string) to the string "sound" to give you "sound1", "sound2", or "sound3"
I'm pretty sure you can use this with regular strings as well, such as:
myHello = "hello " + "world"
good luck
-Adam