0
def calculateTime(a,b,c):
     import datetime
     time = datetime.time(a, b, c)
     print(time)
     newtime = datetime.time(1,0,0)
    delta = time + newtime
    print(delta)


h = int(input()) 
m = int(input())
s = int(input())
#chamando função
calculateHour(h, m, s)

When running, it gives the following error:

Traceback (most recent call last):
   File "c:\Code Phython\arq.py", line, in <module>
     calculateTime(value, value2, value3)
   File "c:\Code Phython\c:\Code Phython\arq.py", line, in calculateTime
     delta = time + newtime
 TypeError: unsupported operand type(s) for +: 'datetime.time' and 'datetime.time'

HOW TO SOLVE?????

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 1
    You're looking for [`timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta), which works with `datetime` and not `time`. See the linked question for what your options are if you need to use `time`. – Silvio Mayolo Jul 13 '22 at 20:42
  • It makes no sense to add times. What does noon + 9am mean? – Barmar Jul 13 '22 at 21:01
  • What are you actually trying to accomplish here? "Adding a number to a time" explains **how** you are solving a problem but doesn't explain what the problem actually is. – Code-Apprentice Jul 13 '22 at 21:02

0 Answers0