From 42ec3e2afc1be06022ea4c1641ce4010f2531fc8 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 9 Sep 2021 10:04:33 +0200 Subject: make format --- tanken.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tanken.py') diff --git a/tanken.py b/tanken.py index b7064cd..19d65c7 100644 --- a/tanken.py +++ b/tanken.py @@ -1,5 +1,6 @@ #!/bin/env python3 + # cost should be given in cents def tanken(drives, cost, service_charge=0): passengers = {} @@ -19,17 +20,19 @@ def tanken(drives, cost, service_charge=0): # collect distances per passenger for p in d[1:]: if p not in passengers: - passengers[p] = {"distance": d[0], - "cost": 0, - "service_charge": 0} + passengers[p] = { + "distance": d[0], + "cost": 0, + "service_charge": 0 + } else: passengers[p]["distance"] += d[0] - + # calculate cost per kilometer if distance <= 0: return None, "Driven distance must be greater than 0!" - c = cost/distance + c = cost / distance for d in drives: # calculate cost per drive split among passengers -- cgit v1.2.3