Python
"""
BASIC LEVEL DEBUGGING EXERCISE

This code has several syntax errors preventing it from running.
Your task:
1. Fix all syntax errors so the code runs without errors
2. Test the code to ensure all methods work correctly
3. Add basic input validation where appropriate

Expected time: 5 minutes
"""

class AppointmentManager:
    def __init__(self):
        self.appointments = [
            {"id": 1, "patient": "Alice Brown", "doctor": "Dr. Smith", "date": "2024-01-15", "duration": 30},
            {"id": 2, "patient": "Bob Wilson", "doctor": "Dr. Jones", "date": "2024-01-16", "duration": 45}
        ]

    def get_appointment(self, appointment_id)
        for appointment in self.appointments:
            if appointment["id"] == appointment_id:
                return appointment
        return None

    def add_appointment(self, appointment):
        for appt in self.appointments:
            if appt["id"] = appointment["id"]:
                raise ValueError("Appointment ID already exists")

        self.appointments.append(appointment)
        return appointment

    def get_by_doctor(self, doctor_name):
        results = []
        for appointment in self.appointments:
            if appointment["doctor"] == doctor_name
                results.append(appointment)
        return results

    def update_duration(self, appointment_id, duration):
        for appointment in self.appointments:
            if appointment["id"] == appointment_id:
                appointment["duration"] = duration
                return appointment

        raise ValueError("Appointment not found"

    def total_time(self):
        total = 0
        for appointment in self.appointments:
            total += appointment["duration"]

        return {"total_minutes": total, "total_hours": total / 60}


if __name__ == "__main__":
    manager = AppointmentManager()

    print(manager.get_appointment(1))
    print(manager.get_by_doctor("Dr. Smith"))
    print(manager.total_time())