Feb-29-2020, 05:28 PM
Hi,
Overall description of need: In the Uk our tax year begins in April. So April is tax month 1. I require an output of the tax month number - example is that February is tax month 11.
The function below is fine as far as I can see but I don't know how to do the last part where I get an output of the tax month from a tuple and I get the error in the title. I may also be approaching it all wrong, and there is a simpler way.
def tax_month_number():
tax_month_tuple = (10,11,12,1,2,3,4,5,6,7,8,9)# tuple for tax months, Jan to Dec but the month numbers are changed to match the tax month
month_number = today.month - 1 #the month number, minus 1 so that February (2), becomes 1. Am trying to match the tuple index so that Feb is tax month 11. Index 1 in tuple is 11
print(month_number)# so I know the output is correct
tax_month = tax_month_tuple()[float(month_number)]#trying to access the tuple index by using the month number
print(tax_month)# doesn't get this far
tax_month_number
Hopefully this is not too complicated a description.
Follows is the function, no description
def tax_month_number():
tax_month_tuple = (10,11,12,1,2,3,4,5,6,7,8,9)
month_number = today.month - 1
print(month_number)
tax_month = tax_month_tuple()[float(month_number)]
print(tax_month)
tax_month_number
Overall description of need: In the Uk our tax year begins in April. So April is tax month 1. I require an output of the tax month number - example is that February is tax month 11.
The function below is fine as far as I can see but I don't know how to do the last part where I get an output of the tax month from a tuple and I get the error in the title. I may also be approaching it all wrong, and there is a simpler way.
def tax_month_number():
tax_month_tuple = (10,11,12,1,2,3,4,5,6,7,8,9)# tuple for tax months, Jan to Dec but the month numbers are changed to match the tax month
month_number = today.month - 1 #the month number, minus 1 so that February (2), becomes 1. Am trying to match the tuple index so that Feb is tax month 11. Index 1 in tuple is 11
print(month_number)# so I know the output is correct
tax_month = tax_month_tuple()[float(month_number)]#trying to access the tuple index by using the month number
print(tax_month)# doesn't get this far
tax_month_number
Hopefully this is not too complicated a description.
Follows is the function, no description
def tax_month_number():
tax_month_tuple = (10,11,12,1,2,3,4,5,6,7,8,9)
month_number = today.month - 1
print(month_number)
tax_month = tax_month_tuple()[float(month_number)]
print(tax_month)
tax_month_number