\n",
"\n",
"
Turn a string into a list
\n",
"\n",
"
\n",
"Use a for-loop to convert the string `\u201chello\u201d` into a list of letters.\n",
"[\"h\", \"e\", \"l\", \"l\", \"o\"]
\n",
"\n",
"NB: you can create an empty list using `my_list = []`\n",
" \n",
"\n",
"\n",
"\n",
"\n",
"
Tuples and Excahnges
\n",
"\n",
"
\n",
"Use a for-loop to convert the string `\u201chello\u201d` into a list of letters.\n",
"[\"h\", \"e\", \"l\", \"l\", \"o\"]
\n",
"\n",
"Explain what the overall effect of this code is:\n",
"\n",
"\n",
"left = 'L'\n",
"right = 'R'\n",
"\n",
"temp = left\n",
"left = right\n",
"right = temp\n",
"
\n",
"
\n",
"Compare it to:\n",
" left, right = right, left
\n",
"
\n",
"Do they always do the same thing? Which does your brain scan better?\n",
"\n"
],
"cell_type": "markdown",
"metadata": {}
},
{
"source": [],
"cell_type": "markdown",
"metadata": {}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"name": "python2",
"language": "python2"
},
"language_info": {
"mimetype": "text/x-python",
"nbconvert_exporter": "python",
"name": "python",
"file_extension": ".py",
"version": "2.7.11",
"pygments_lexer": "ipython2",
"codemirror_mode": {
"version": 2,
"name": "ipython"
}
}
}
}