Whenever i run the programme, it comes up with either errors
Traceback (most recent call last):
File "C:\Users\mrosales\Downloads\Rock Paper Sissor Tornament.py", line 46, in <module>
Temp = ClassList[Random2]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Users\mrosales\Downloads\Rock Paper Sissor Tornament.py", line 60, in <module>
Temp = ClassList[Random2]
IndexError: list index out of range
My code is about moving strings from one list to another to form set games of a tornamnet
import random
import time
Temp = (" ")
ClassList = ['Noah','Simone','Ji Ho','Thanh','Nathanial','Soo','Mickel','Tuan']
Match1 = [], Match2 = [], Match3 = [] ,Match4 = []
Random1 = random.randrange(0,len(ClassList))
Random2 = random.randrange(0,len(ClassList))
while Random1 == Random2:
Random1 = random.randrange(0,len(ClassList))
time.sleep(1)
Temp = ClassList[Random1]
Match1.append(Temp)
del ClassList[Random1]
Temp = ClassList[Random2]
del ClassList[Random2]
Match1.append(Temp)
print(Match1)
Random1 = random.randrange(0,len(ClassList))
Random2 = random.randrange(0,len(ClassList))
while Random1 == Random2:
Random1 = random.randrange(0,len(ClassList))
time.sleep(1)
Temp = ClassList[Random1]
Match2.append(Temp)
del ClassList[Random1]
Temp = ClassList[Random2]
del ClassList[Random2]
Match2.append(Temp)
print(Match2)
Random1 = random.randrange(0,len(ClassList))
Random2 = random.randrange(0,len(ClassList))
while Random1 == Random2:
Random1 = random.randrange(0,len(ClassList))
time.sleep(1)
Temp = ClassList[Random1]
Match3.append(Temp)
del ClassList[Random1]
Temp = ClassList[Random2]
del ClassList[Random2]
Match3.append(Temp)
print(Match3)
Random1 = random.randrange(0,len(ClassList))
Random2 = random.randrange(0,len(ClassList))
while Random1 == Random2:
Random1 = random.randrange(0,len(ClassList))
time.sleep(1)
Temp = ClassList[Random1]
Match4.append(Temp)
del ClassList[Random1]
Temp = ClassList[Random2]
del ClassList[Random2]
Match4.append(Temp)
print(Match4)
Random1 = random.randrange(0,len(ClassList))
Random2 = random.randrange(0,len(ClassList))
while Random1 == Random2:
Random1 = random.randrange(0,len(ClassList))
print ("The current match ups are...")
print (Temp)
time.sleep(1)
print (Match1, Match2, Match3, Match4)
Can anyone spot an error I may have placed and, if they wish, correct it?