Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion for-loops.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"cast = [\"odysseus\", \"neoptolemus\", \"philoctetes\"]\n",
"\n",
"for character in cast:\n",
"print(character)\n",
" print(character)\n",
"\n",
"print(\"And now the loop is done!\")"
]
Expand Down Expand Up @@ -304,6 +304,30 @@
"\n",
"Matthes 2023, p. 67, Exercise 4-13."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Define the tuple\n",
"buffet = (\"rice\", \"chicken\", \"salad\", \"soup\", \"pasta\")\n",
"\n",
"# Use a for loop to print each food\n",
"print(\"Original menu:\")\n",
"for food in buffet:\n",
" print(food)\n",
"\n",
"\n",
"# Rewrite the tuple\n",
"buffet = (\"rice\", \"chicken\", \"steak\", \"sandwich\", \"pasta\")\n",
"\n",
"# Print the updated menu\n",
"print(\"\\nUpdated menu:\")\n",
"for food in buffet:\n",
" print(food)"
]
}
],
"metadata": {
Expand Down