Ask coding questions

← Back to all posts
How to figure out what the computer did
51LV3RC0D3R (22)

So I am creating a Simon Says game in which the computer shows a random pattern and the user has to remember the pattern, and each time it shows the pattern for less and less time. So I was wondering how to know what pattern the computer is creating.

Answered by AlexanderTarn (288) [earned 5 cycles]
View Answer
Comments
hotnewtop
AlexanderTarn (288)

You could try to use a list to store the variables of the rectangles the program creates.

51LV3RC0D3R (22)

@AlexanderTarn yeah i could, but I was wondering how i mean like I would use

cpu = [yellowbtn1,...]

but I use

for i in range(4)

so that wouldn't work exactly.

AlexanderTarn (288)

@51LV3RC0D3R have you tried iterating through the list?

cpu = [yellowbtn1, redbtn1, bluebtn1, greenbtn1]
for i in cpu:
  print(cpu)

output:

yellowbtn1
redbtn1
bluebtn1
greenbtn1
51LV3RC0D3R (22)

Thanks, but I figure out how to do it!