What this program should do is traverse the array using two loops and take everything in the first set that isn't a number and make it into a key. The keys aren't being added to the dictionary in the order I would expect. There's more to the class but here is the part that is giving me troubles.
class Sorter():
def __init__(self, vals):
self.vals = vals
def borda(self):
bordaContainer = { }
arrayLength = len(self.vals)
for outsides in range(arrayLength):
for insides in range(len(self.vals[outsides])):
currentChoice = self.vals[outsides][insides]
if outsides ==0 and insides != len(self.vals[outsides])-1:
bordaContainer[currentChoice] = ''
return bordaContainer
inputArray = [['A','B','C','D',10],['C','D','B','A',4],['D','A','B','C',7]]
first = Sorter(inputArray)
print first.borda()
The result:
{'A': '', 'C': '', 'B': '', 'D': ''}
I should be getting {'A': '', 'B': '', 'C': '', 'D': ''}. Any explanation to what is happening would be great, thank you!