How to use python to control a lot of objects?

I would like to create about 100 Cubes, and let them move randomly.
but I am getting 2 problems:

  1. how to create and initial objects when game start, and destroyed them when game end?

  2. can I use a for loop on these objects? I found when I create a new Cube it will be auto named by Cube.002 Cube.003 … But when I use for loop with a variable i and get the name by [‘Cube.’+i] it should be Cube.1 Cube.2 …I have no ideas with the zeros.

English is not my native language, please tell me if I didn’t make the question clear.

Thanks very much!:slight_smile:

You can write. [“OBCube”+"%03d" %i]
If you use Blender 2.49b, don’t forget to write OB in front of your object.