Time Calculator - FCC project - Days

Hi guys,

I am working on the second project at FCC, the Time Calculator, and all working, passing tests except the days. This is part for the day code, getting error message: TypeError: unhashable type: ‘list’

Any hint/advice?

#day - list
#days_of_week - dictionary
 #day_key - list

day = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
day_key = [1, 2, 3, 4, 5, 6, 7]

days_of_week = { "Monday" : 1,
        "Tuesday" : 2,
        "Wednesday" : 3,
        "Thursday" : 4,
        "Friday" : 5,
        "Saturday" : 6,
        "Sunday" : 7}

if day:
    
    day_value = int(days_of_week[day] + n) % 7
    new_day = day[day_value]
        
    #for example
    # day = starting day, n days later
day = "Tuesday"            
n = 16     

I’m assuming the line with error is

    day_value = int(days_of_week[day] + n) % 7

Could you explain what this line should be doing? Then compare it with what actually is happening, considering what, at that point, each variable is.

i was aiming to get value for the day of the week + days from that day and 7 was max value so it will reset again, for example:

day_value = int(days_of_week[Tuesday] + 16 days from tuesday
so (2 + 16) % 7
which means 4 so result should be Thursday

Okay, but when that line is executed day contains list with all days.

ah, i thought it will execute once i put some spec day and number of days (as in example) and print one day only

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.