Help with TypeError: unsupported operand type(s) for +: 'int' and 'str'

Hello I am new to python. I have completed the Time calculator. But I have been able to correct this 2 errors. Join Yemisow's "boilerplate-time-calculator (4)" - Replit

so you have this error:

==============
ERROR: test_twenty_four_with_day (test_module.UnitTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/boilerplate-time-calculator-4/test_module.py", line 53, in test_twenty_four_with_day
    actual = add_time("2:59 AM", "24:00", "saturDay")
  File "/home/runner/boilerplate-time-calculator-4/time_calculator.py", line 127, in add_time
    new_day_index = (index_day_of_week + (added_days)) % 7
TypeError: unsupported operand type(s) for +: 'int' and 'str'

What do you think it is trying to tell you?

i have tried to trace why i am getting strings instead of intergers

there are 2 ways to deal with this. You can try to figure out why something is a string or you can just convert it to an integer when you need an integer.
It depends on what you are trying to do or what makes sense.

I am not expecting a string. i have spent alot of hours on this and I have not been able to figure the error. At this point maybe another set of eyes would be able to point out the error. if i put int, I get another error
ValueError: invalid literal for int() with base 10: ‘’

please post a link to the challenge or exercise description in your top post…

have you tried to log the values? What are you getting when you log them just before the line that causes the error?

so the issue is from added_days which is an empty string
added_days = “”

What is the purpose of this string?

Thanks alot. make sense to initialize it to zero.

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