Python Forum
TypeError: 'tuple' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: 'tuple' object is not callable
#1
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
Reply
#2
 tax_month = tax_month_tuple()[float(month_number)]#trying to access the tuple index by using the month number
Why do you have the parens after tax_month_tuple? It isn't a function, so that's why you get the error.

Also, please remember to post code within the right tags so indentation, highlighting and line numbering are all present.
Reply
#3
Of course! Just couldn't see it.

And yes, will post within correct tags in future.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: cannot pickle ‘_asyncio.Future’ object Abdul_Rafey 1 369 Mar-07-2024, 03:40 PM
Last Post: deanhystad
  error in class: TypeError: 'str' object is not callable akbarza 2 498 Dec-30-2023, 04:35 PM
Last Post: deanhystad
Bug TypeError: 'NoneType' object is not subscriptable TheLummen 4 735 Nov-27-2023, 11:34 AM
Last Post: TheLummen
  TypeError: 'NoneType' object is not callable akbarza 4 983 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,335 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 822 Jul-23-2023, 02:25 PM
Last Post: Fare
  TypeError: 'float' object is not callable #1 isdito2001 1 1,074 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  TypeError: a bytes-like object is required ZeroX 13 4,070 Jan-07-2023, 07:02 PM
Last Post: deanhystad
  'SSHClient' object is not callable 3lnyn0 1 1,166 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,434 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020