From cb5bf46814d580668db58cdec42919b42a2b604c Mon Sep 17 00:00:00 2001 From: Afonso Date: Wed, 19 Apr 2023 19:02:39 +0100 Subject: [PATCH] Did what I could --- your-code/challenge-1.ipynb | 52 ++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/your-code/challenge-1.ipynb b/your-code/challenge-1.ipynb index c574eba..13e30d9 100644 --- a/your-code/challenge-1.ipynb +++ b/your-code/challenge-1.ipynb @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -33,12 +33,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'Durante un tiempo no estuvo segura de si su marido era su marido.'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "str_list = ['Durante', 'un', 'tiempo', 'no', 'estuvo', 'segura', 'de', 'si', 'su', 'marido', 'era', 'su', 'marido']\n", - "# Your code here:\n" + "\n", + "\" \".join(str_list) + \".\"" ] }, { @@ -50,12 +62,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Grocery list: bananas, bread, brownie mix, broccoli.\n" + ] + } + ], "source": [ "food_list = ['Bananas', 'Chocolate', 'bread', 'diapers', 'Ice Cream', 'Brownie Mix', 'broccoli']\n", - "# Your code here:\n" + "\n", + "# First I've created the grocery list:\n", + "\n", + "grocery_lst = \"Grocery list: \"\n", + "\n", + "# Then I've used a list compreheension to iterate over the food_list to extract the foods that start with the letter \"b\",\n", + "# and to make all the words lowercase, using the .lower() method. \n", + "\n", + "foods = [food.lower() for food in food_list if food.lower().startswith('b')]\n", + "\n", + "# I've finally added the ponctuation using the .join() method. \n", + "\n", + "grocery_lst += ', '.join(foods) + '.'\n", + "\n", + "print(grocery_lst)\n" ] }, { @@ -226,7 +260,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -240,7 +274,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.8" + "version": "3.9.13" } }, "nbformat": 4,