These are the instructions and I got this so far: My code doesn\'t work. How sho
ID: 3812103 • Letter: T
Question
These are the instructions and I got this so far:
My code doesn't work. How should I solve the problem?
Part I: Recording a Repair (3 points) Write a function record-repair that records a repair for a car and returns the total cost of all repairs for that car (including the new repair). The function takes four arguments, in this order: cars: a list of Car objects vin: the VIN for the car that we want to record a repair for repair-desc: a description of the repair repair-cost: the cost of the repair (an integer) The function must search the list of Car objects for the car with the given vin, call the add-repair method of the Car class with the given repair desc and repair-cost to record a repair for the car, and then return CSE 101 Spring 2017 Lab #8 Page 2 the new total repair costs for the car. If no Car object is found in the list cars with the given vin, the function should simply return 0 Examples: While looking at the examples in this document, you should have open then provided lab8.py file so that you can see exactly what are the contents of cars1, cars2 and cars 3. Return Value Function Call record repair (carsi, HSY113Y', Punctured tire', 40) 1040 record repair (cars1, MZJ2 91E', Cracked rim' 800) 800 record repair (cars1, XYZ123x', 'Broken mirror', 250) 0Explanation / Answer
I think all is in order. Please check the following line of def record_repair(cars, vin, repair_desc, repair_cost)
for car In cars: // Here , please check the syntax for the "In" keyword, whether it is capitals or smalls.
If num == vin //Please check syntax and case sensitivity for the If keyword.
Everything else seems fine. Also try tweaking the if conditions as the major part is okay and should return the values properly. As it is very rightly said, you learn by making mistakes and playing on those.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.