FIX: every exercices of module 02

This commit is contained in:
2026-01-30 19:21:16 +01:00
parent acc6d274c2
commit 5b91191c20
6 changed files with 208 additions and 101 deletions

View File

@@ -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__":