I am making a code that generates a Rubik's cube scramble and I used if scramble:
to see if there was anything in the list in the for loop. I am unsure of how to check if there is anything in list index > 0. The code is here (please don't judge my coding, it's not final I still have some cleaning up to do of the code and I am only doing GCSE computer science at the moment)
scrambling = True
while scrambling:
scramble = []
for i in range(0,30):
while True:
chosen = r.choice(moves)
if scramble:
if scramble[i-1] != chosen:
if chosen[0] != scramble[i-1][0]:
break
else:
pass
else:
pass
else:
break
scramble.append(chosen)
if opposites[scramble[15]] != opposites.get(scramble[16]):
if opposites[scramble[14]] != opposites.get(scramble[15]):
scrambling = False
else:
pass
else:
pass
Thanks for any help
You can check the length of the list: