Fix indentation rendering in nbviewer for if-block

pull/9/head
Tim Skov Jacobsen 2019-11-22 11:06:22 +01:00
parent 3d31ef8fa4
commit c33ad9d3e8
1 changed files with 67 additions and 55 deletions

View File

@ -108,7 +108,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that strings are ***immutable***, which means that they can't be changed after creation. They can be copied into a new variable and thereafter manipulated though."
"Note that strings are ***immutable***, which means that they can't be changed after creation. They can be copied, then manipulated and thereafter saved into a new variable though."
]
},
{
@ -406,9 +406,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "TypeError",
"evalue": "unsupported operand type(s) for -: 'str' and 'str'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-15-f52d61c1bb56>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;34m'a'\u001b[0m \u001b[1;33m-\u001b[0m \u001b[1;34m'b'\u001b[0m \u001b[1;31m# Subtraction results in error\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'str' and 'str'"
]
}
],
"source": [
"'a' - 'b' # Subtraction results in error"
]
@ -429,7 +441,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 16,
"metadata": {},
"outputs": [
{
@ -451,7 +463,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"outputs": [
{
@ -476,7 +488,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 18,
"metadata": {},
"outputs": [
{
@ -501,7 +513,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 19,
"metadata": {},
"outputs": [
{
@ -510,7 +522,7 @@
"3"
]
},
"execution_count": 18,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
@ -521,7 +533,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 20,
"metadata": {},
"outputs": [
{
@ -530,7 +542,7 @@
"7"
]
},
"execution_count": 19,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
@ -549,7 +561,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
@ -569,7 +581,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 22,
"metadata": {},
"outputs": [
{
@ -578,7 +590,7 @@
"'Ed Snowden'"
]
},
"execution_count": 21,
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
@ -591,14 +603,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Recall that strings are ***immutable***. They can be copied and saved to a new variable and thereafter manipulated. But they can't be changed per se. This concept transfers to other more complex constructs as well.\n",
"Recall that strings are ***immutable***. They can be copied, manipulated and saved to a new variable. But they can't be changed per se. This concept transfers to other more complex constructs as well.\n",
"\n",
"Thus, the original string called `name` is still the same:"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 23,
"metadata": {},
"outputs": [
{
@ -607,7 +619,7 @@
"'Edward Snowden'"
]
},
"execution_count": 22,
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
@ -625,7 +637,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
@ -653,7 +665,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 25,
"metadata": {},
"outputs": [
{
@ -662,33 +674,13 @@
"False"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name.endswith('g')"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name.endswith('n')"
"name.endswith('g')"
]
},
{
@ -707,6 +699,26 @@
"output_type": "execute_result"
}
],
"source": [
"name.endswith('n')"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"name.endswith('den')"
]
@ -725,7 +737,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 28,
"metadata": {},
"outputs": [
{
@ -734,7 +746,7 @@
"4"
]
},
"execution_count": 27,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
@ -746,7 +758,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 29,
"metadata": {},
"outputs": [
{
@ -755,7 +767,7 @@
"3"
]
},
"execution_count": 28,
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
@ -773,7 +785,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 30,
"metadata": {},
"outputs": [
{
@ -782,7 +794,7 @@
"1"
]
},
"execution_count": 29,
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
@ -801,11 +813,11 @@
"### Syntax of conditional blocks\n",
" \n",
"```python\n",
" if condition:\n",
" # Code goes here (must be indented!)\n",
" # Otherwise, IndentationError will be thrown\n",
"if condition:\n",
" # Code goes here (must be indented!)\n",
" # Otherwise, IndentationError will be thrown\n",
"\n",
" # Code placed here is outside of the if-statement \n",
"# Code placed here is outside of the if-statement \n",
"```\n",
"\n",
"Where evaluation of `condition` must return a boolean (`True` or `False`).\n",
@ -838,7 +850,7 @@
},
{
"cell_type": "code",
"execution_count": 30,
"execution_count": 31,
"metadata": {},
"outputs": [
{
@ -864,7 +876,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 32,
"metadata": {},
"outputs": [
{
@ -892,7 +904,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 33,
"metadata": {},
"outputs": [
{
@ -1052,7 +1064,7 @@
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": 34,
"metadata": {},
"outputs": [
{
@ -1325,7 +1337,7 @@
"<IPython.core.display.HTML object>"
]
},
"execution_count": 33,
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
@ -1353,7 +1365,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.1"
"version": "3.7.4"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,