Method i have written works but my question is whether it is written in a Pythonic style. Any suggestions to improve the style are welcome.
def findTourCost(self, tour):
total = 0
for index, value in enumerate(tour):
if index == len(tour) - 1:
total = total + self.costMatrix[value][tour[0]]
break
total = total + self.costMatrix[value][tour[index + 1]]
return total

New Topic/Question
Reply



MultiQuote




|