Place random familyType with Python


I’d like to place random families with Python. I have a working code to place one family type with Python

But my wish is that it picks a random family from the listRandom, so item.Symbol = Random listRandom value or something.

See below code:


Try using a random int to select an item in your list. See here for how to make random numbers…

In your case what you should do is…

item.symbol = listRandom[random.randint(0, len(listRandom)-1]

Make sure you also import random library first.

Also, for the family types, i would import them all as one list called listRandom instead of having a port for each family type. This way, you can have any length of list without having to manually add to listRandom in code.


Thanks for helping.

I’ve done the things you said but i get the unexpected token ] error from your code


You are missing an ‘)’ before the ‘]’ on line 27. When you see this kind of error, it is a good indicator you haven’t closed out with ).

Thanks, that i didn’t see that :-S

Last question, can you build something in Python that you can make sure it is never uses the same family next to each other?

This is the working solution:

Might i ask what your ‘‘count’’ is accomplishing? :slight_smile: