From bdc9964e4735e8f18364dfcb277dc6a7126b0fba Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Sat, 29 Mar 2025 12:50:22 -0500 Subject: [PATCH] Add helper functions for List --- helpers/list_helpers.py | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 helpers/list_helpers.py diff --git a/helpers/list_helpers.py b/helpers/list_helpers.py new file mode 100644 index 0000000..8e22007 --- /dev/null +++ b/helpers/list_helpers.py @@ -0,0 +1,65 @@ +from typing import List + +def is_asian_car(car_make: str) -> bool: + """ + Check if a given car make is from an Asian manufacturer. + + Args: + car_make (str): The car make to check. + + Returns: + bool: True if the car make is Asian, False otherwise. + """ + asian_car_makers = [ + 'toyota', 'honda', 'nissan', 'mazda', 'subaru', 'mitsubishi', + 'suzuki', 'lexus', 'infiniti', 'acura', 'hyundai', 'kia', + 'genesis', 'ssangyong', 'isuzu', 'daihatsu' + ] + return car_make.lower() in asian_car_makers + +def filter_asian_cars(cars: List[str]) -> List[str]: + """ + Filter a list of car makes to include only Asian car makes. + + Args: + cars (List[str]): A list of car makes. + + Returns: + List[str]: A list of Asian car makes. + """ + return [car for car in cars if is_asian_car(car)] + +def get_asian_car_list() -> List[str]: + """ + Get a list of common Asian car makes. + + Returns: + List[str]: A list of Asian car makes. + """ + return [ + 'Toyota', 'Honda', 'Nissan', 'Mazda', 'Subaru', 'Mitsubishi', + 'Suzuki', 'Lexus', 'Infiniti', 'Acura', 'Hyundai', 'Kia', + 'Genesis', 'SsangYong', 'Isuzu', 'Daihatsu' + ] + +def sort_asian_cars(cars: List[str]) -> List[str]: + """ + Sort a list of Asian car makes in alphabetical order. + + Args: + cars (List[str]): A list of Asian car makes. + + Returns: + List[str]: A sorted list of Asian car makes. + """ + return sorted(cars) + +def print_asian_cars(cars: List[str]) -> None: + """ + Print a list of Asian car makes. + + Args: + cars (List[str]): A list of Asian car makes. + """ + for car in cars: + print(car) \ No newline at end of file