How to return the index of an array in a for loop?
Posted: Thu Sep 06, 2018 11:58 am
Code: Select all
for item in arrayTest:
# what index array number are we on ?
text arrayTest.index(item) + "\n"
Supporting creators of visual novels and story-based games since 2003.
https://lemmasoft.renai.us/forums/
Code: Select all
for item in arrayTest:
# what index array number are we on ?
text arrayTest.index(item) + "\n"
Code: Select all
i = 0
for item in arrayTest:
(Use i as the index)
i += 1
Code: Select all
for i in range(len(arrayTest)):
text arrayTest[i]
Code: Select all
vbox:
$ index = 10
for item in reversed(arrayTest):
text "[index]"
$ index -= 1
Code: Select all
for idx, item in enumerate( arrayTest ):
text "[idx] : [item]"