array and for loop

i made 931 token positions, but of course this was a large chunk of code which made my application really laggy

i asked a few others and they all mentioned about array and for loop

currently the large chunk of code looks like this

note that droplet is a class of…well…a water droplet which happens to be my token

i guess array and for loop is a god way to optimise a large number of the same thing

ive no knowledge of array and for loop so i am hoping someone would be kind enough to elaborate

if you have no knowledge of arrays and loops you REALLY should work through some python tutorials. you cant really live without those when coding.

self.dropList=[]
for number in range(0,931):
  self.dropList.append(droplet.droplet(loca.find("**/locator"+str(number)).getPos(),self.char)) 

later on you can access any element of the list by doing

self.dropList[theelementnumberyouwant]

ps: dont just copy&paste that code… learn how to use loops and lists. those are essential!

yeah i know that at the back of my head…

i just wish that i had more time to get to know the python language before my project was due which is within a matter of days