Error in CS50P Problem Set 7 working 9 to 5 “:( test_working.py catches working.py not raising ValueError when user omits ” to “”
🙁 test_working.py catches working.py not raising ValueError when user omits ” to “
Error in CS50P Problem Set 5 working 9 to 5
import re import sys pattern = r”(d?d):?(d{2})? ([AP]M)” def main(): print(convert(input(“Hours: “))) def convert(s): if hours := re.search(f”(?P<start_time>{pattern}) to (?P<end_time>{pattern})”, s): start_time = convert_time(hours.group(“start_time”)) end_time = convert_time(hours.group(“end_time”)) return f”{start_time} to {end_time}” raise ValueError def convert_time(time): match = re.search(pattern, time) hour = int(match.group(1)) minute = int(match.group(2)) if match.group(2) else 0 am_or_pm = match.group(3) if not is_valid(hour, […]