Ask coding questions

← Back to all posts
I need help PLEASE!
crazyCoder691 (8)

I have this list called display_list. Whenever the next level starts, I add a random number to it like this:

from random import randint
color = rand(0, 3)
display_list.append(color)

what I want it to do is this

index = the_first_number_in_display_list
if display_list[index] is 0:
    do this
if display_list[index] is 1:
    do this other thing

and so on till 4...
then do this

index = the_next_number_in_display_list

and repeat:

if display_list[index] is 0:
    do this
if display_list[index] is 1:
    do this other thing

until all the numbers in display list are gone through

Commentshotnewtop
DynamicSquid (3224)

I don't know Python, but here should be a general idea of what you're aiming for:

list = 0, 1, 2, 3, 4, 5
increment = 0

while increment < list_size:
    if list[increment] == 0:
        do_something
    else if list[increment] == 1:
        do_something
    else if list[increment] == 2:
        do_something

    increment += 1;

Hope this helps!