I'm trying to write a program in which I can input a list and if all the values in the list are equal, it returns the boolean Yahtzee as True. When I run it, it works 99% of the time. However, index 3 can be different than the other values in the list and isYahtzee()
will still return Yahtzee as True. Can someone help me debug this?
#Determine whether all of them are the same and returns a Boolean.
def isYahtzee(aList):
#This tells the program to look down the entire length of the list
for i in range (0,len(aList)):
#Since I will be working with a list with no more than 5 numbers, I se
#This equal to 5 indexs (0-4)
if aList[0] == aList[1] and aList[1] and aList[2] and aList[3] and aList[4]:
#If all of them are equal, the boolean Yahtzee = True
Yahtzee = True
#If they are not all equal to eachother
if aList[0] != aList[i]:
#The Boolean Yahtzee = False
Yahtzee = False
#Return the value of the Boolean
return Yahtzee