TypeError: 'function' object is not subscriptable - Python

后端 未结 3 1241
忘了有多久
忘了有多久 2020-12-06 05:41

I\'ve tried to solve an assignment with this code:

bank_holiday= [1, 0, 1, 1, 2, 0, 0, 1, 0, 0, 0, 2] #gives the list of bank holidays in each month

def ban         


        
3条回答
  •  死守一世寂寞
    2020-12-06 06:40

    You can use this:

    bankHoliday= [1, 0, 1, 1, 2, 0, 0, 1, 0, 0, 0, 2] #gives the list of bank holidays in each month
    
    def bank_holiday(month):
       month -= 1#Takes away the numbers from the months, as months start at 1 (January) not at 0. There is no 0 month.
       print(bankHoliday[month])
    
    bank_holiday(int(input("Which month would you like to check out: ")))
    

提交回复
热议问题