Editor settings

General settings

Save settings

Learn to program with Python

Change the time #

Write a function that updates the time given the current time in 24-hour format as a string, e.g. 15:00, and an integer to change the time. The integer can be positive or negative, indicating the number of minutes to add or subtract from the current time. The function should return a string representing the updated time.


Tests #

  • change_time("12:30", 45) should return "13:15"
  • change_time("23:45", -90) should return "22:15"
  • change_time("06:00", 120) should return "08:00"
  • change_time("09:15", -60) should return "08:15"
  • change_time("18:30", 0) should return "18:30"
  • change_time("23:55", 10) should return "00:05"
  • change_time("00:05", -10) should return "23:55"
Output will be displayed here