Commit 80d2c30e authored by Holger Dinkel's avatar Holger Dinkel

add debug exercise to 4_NestedDataStructures.ipynb

parent a2cad2a6
......@@ -656,6 +656,38 @@
"* Individual entries can be accessed by stacking up indices/keys, which Python interprets one at a time, from left to right.\n",
"* The values of variables can be inserted into strings, with their format controlled, using the `.format()` string method."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Debugging exercise"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this exercise, you are presented with some code that doesn't work as it should. Your task is to debug it."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# You start with a group of students and scores and you would like to print the name and the score of each.\n",
"# Can you spot and fix the errors?\n",
"# Hint: Each line contains at least one error/mistake\n",
"\n",
"group = '{Sarah:20, Richard:30, Matthew:40, Fiona:50, Sally:60, Samuel:70}'\n",
"\n",
"for student in group_of_students:\n",
" print(\"The score of {} is {}\".format(student, group(student))\n"
]
}
],
"metadata": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment