mirror of
https://github.com/DavidGailleton/42-Piscine_Python.git
synced 2026-03-14 05:06:55 +01:00
FIX: every exercices of module 02
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
def water_plants(plant_list: []) -> None:
|
||||
def water_plants(plant_list: list[str | None]) -> None:
|
||||
"""Display watering plant if plant is a string"""
|
||||
for plant in plant_list:
|
||||
if plant == None:
|
||||
raise ValueError
|
||||
@@ -6,7 +7,10 @@ def water_plants(plant_list: []) -> None:
|
||||
|
||||
|
||||
def test_watering_system() -> None:
|
||||
"""Tester for water_plants() function"""
|
||||
plants = ["tomato", "lettuce", "carrots", None]
|
||||
print("=== Garden Watering System ===")
|
||||
print("\nTesting normal watering...")
|
||||
try:
|
||||
print("Opening watering system")
|
||||
water_plants(plants)
|
||||
@@ -14,6 +18,7 @@ def test_watering_system() -> None:
|
||||
print("Error: Cannot water None - invalid plant!")
|
||||
finally:
|
||||
print("Closing watering system (cleanup)")
|
||||
print("\nCleanup always happens, even with errors")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user