-6

I'm trying to implement in Python the following logic.

# Variable i = loop (1 to 32)

days = dict()

    if i in days: # if there's already a Key in the dict
        variable_time = str(days[i])
        hours_time = variable_time .split(':')[0]
        minutes_time = variable_time .split(':')[1]

        # It should sum the current value to the new value
        time_horizontal = timedelta(hours=int(hours_time), minutes=int(minutes_time))
        total_horizontal[i] = time_horizontal + timedelta(hours=int(hours_), minutes=int(minutes_))
    else:
        # otherwise, it will insert the default values
        total_horizontal[i] = timedelta(hours=int(hours_), minutes=int(minutes_)) # this will get info from other variables

With this code, I'm getting the following error:

Exception: Unexpected data type type 'datetime.timedelta'

How can I solve it? Thanks.

user2742861
  • 340
  • 1
  • 8
  • 17
  • 5
    We have no idea, because you have not shown where this error is occurring, nor posted the full traceback. What we can tell you is that it is clearly not being raised from any of the code you have posted. – Daniel Roseman Sep 18 '13 at 10:39
  • Actually, the problem was on the code I've posted. Resolution in the answer below. – user2742861 Sep 18 '13 at 10:53

1 Answers1

-1

Solved

# Variable i = loop (1 to 32)

    days = dict()

        if i in days:
            variable_time = str(days[i])
            hours_time = variable_time .split(':')[0]
            minutes_time = variable_time .split(':')[1]

            time_horizontal = timedelta(hours=int(hours_time), minutes=int(minutes_time)) + timedelta(hours=int(hours_), minutes=int(minutes_)) 
            total_horizontal[i] = str(time_horizontal)
        else:
            # otherwise, it will insert the default values
            total_horizontal[i] = str(timedelta(hours=int(hours_), minutes=int(minutes_)))
user2742861
  • 340
  • 1
  • 8
  • 17