I have three similarmethods. And I think this can be reduced to one method.
So I have this almost identical methods:
def calulate_totalAnanas_NorthMidSouth():
sheet_factuur = excelWorkbook['Facturen ']
totalAnanasNorth = sheet_factuur.cell(row=6, column=5).value
totalAnanasMid = sheet_factuur.cell(row=7, column=5).value
totalAnanasSouth = sheet_factuur.cell(row=8, column=5).value
totalAnanasNoMidSou = totalAnanasNorth + totalAnanasMid + totalAnanasSouth
print(totalAnanasNoMidSou)
def calulate_totalApples_NorthMidSouth():
sheet_factuur = excelWorkbook['Facturen ']
totalAppleNorth = sheet_factuur.cell(row=9, column=5).value
totalApplesMid = sheet_factuur.cell(row=10, column=5).value
totalAppleSouth = sheet_factuur.cell(row=11, column=5).value
totalAppleNoMidSou = totalAppleNorth + totalApplesMid + totalAppleSouth
print(totalAppleNoMidSou)
def calulate_totalWaspeen_NorthMidSouth():
sheet_factuur = excelWorkbook['Facturen ']
totalWaspeenNorth = sheet_factuur.cell(row=12, column=5).value
totalWaspeenMid = sheet_factuur.cell(row=13, column=5).value
totalWaspeenSouth = sheet_factuur.cell(row=14, column=5).value
totalWaspeenNoMidSou = totalWaspeenNorth + totalWaspeenMid + totalWaspeenSouth
print(totalWaspeenNoMidSou)
So my question is:how to refactor this?