From d8e84c349ef348391cca465aa08b34ae17c89cd7 Mon Sep 17 00:00:00 2001 From: eslopfer Date: Thu, 19 Jan 2023 15:36:04 +0000 Subject: [PATCH] feat(clean_the_list): add solution for exercise --- sh/tests/solutions/shopping.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 sh/tests/solutions/shopping.py diff --git a/sh/tests/solutions/shopping.py b/sh/tests/solutions/shopping.py new file mode 100644 index 00000000..75c13af5 --- /dev/null +++ b/sh/tests/solutions/shopping.py @@ -0,0 +1,9 @@ +def clean_list(shopping_list): + if shopping_list: + cleaned_list = ([f"{index + 1}x/ {item.strip().capitalize()}" + for index, item in enumerate(shopping_list)]) + if "milk" not in cleaned_list: + cleaned_list.append("milk") + return cleaned_list + else: + return []