lordty-tf33y7/helpers/list_helpers.py
2025-03-29 12:50:22 -05:00

65 lines
1.7 KiB
Python

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)