Need trouble with my car wash program assignment

my current code:

def car_wash_service(base_price, dictionary, service1, service2):
    total_price = base_price
    service_list = {service2, service1}
    print('ZyCar Wash')
    print(f'Base car wash -- ${base_price}')
    for service in service_list:
        if service in dictionary.keys():
            print(f'{service} -- ${dictionary[service]}')
            total_price += dictionary[service]
    print('----')
    print(f'Total price: ${total_price}')
    return total_price


if __name__ == "__main__":
    services = {'Air freshener': 1, 'Rain repellent': 2, 'Tire shine': 2, 'Wax': 3, 'Vacuum': 5}
    base_wash = 10
    total = 0
    service_choice1 = input()
    service_choice2 = input()
    car_wash_service(base_wash, services, service_choice1, service_choice2)

my error:
1:Compare outputkeyboard_arrow_up

0 / 2

Output differs. See highlights below. Special character legend

Input

Tire shine Wax

Your output starts with

ZyCar Wash Base car wash – $10 Wax – $3 Tire shine – $2 ---- Total price: $15

Expected output starts with

ZyCar Wash Base car wash – $10 Tire shine – $2 Wax – $3 ---- Total price: $15

2:Compare outputkeyboard_arrow_up

3 / 3

Input

Rain repellent -

Your output

ZyCar Wash Base car wash – $10 Rain repellent – $2 ---- Total price: $12

3:Compare outputkeyboard_arrow_up

3 / 3

Input

Vacuum Air freshener

Your output

ZyCar Wash Base car wash – $10 Vacuum – $5 Air freshener – $1 ---- Total price: $16

4:Compare outputkeyboard_arrow_up

2 / 2

Input

Your output correctly ends with

ZyCar Wash Base car wash – $10 ---- Total price: $10

5:Unit testkeyboard_arrow_up

2 / 2

car_wash_service() with the first example

Your output

ZyCar Wash Base car wash – $10 ---- Total price: $10

6:Unit testkeyboard_arrow_up

2 / 2

car_wash_service() with the second example

Your output

ZyCar Wash Base car wash – $13 Tire shine – $16 Air freshener – $20 ---- Total price: $49

Answer 1 looks correct to me; it’s just that the order is different, which shouldn’t matter.

1 Like

I do not understand your output of the test except this part which looks like an error in the testing code (not in your program) as Matthew noted:

I think you should explain the test output and tell what it has evaluated as being wrong.

even then, the grading system would not accept the order.
it needs to be in the exact order as implied.

You can reorder the entries of services as a workaround. That should work because in recent versions of Python dicts retain their insertion order.