Sure, just do a loop, like "for (i=0; i=random(from,to); i++):"
The random in that place should find the last execution of the loop, and then execute the loop that quantity of times.
I don't know the actual implementation because I have not learned Python yet, but that's the basic structure of what you want to do... I guess...
Off-topic: Sorry for the bad english, still not fully awaken.