Skip to content

Commit 8fc457b

Browse files
committed
Added one more example
1 parent f58fe6b commit 8fc457b

1 file changed

Lines changed: 49 additions & 2 deletions

File tree

Sep21/EssentialPython/tuples/tuples.ipynb

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,62 @@
201201
},
202202
{
203203
"cell_type": "code",
204-
"execution_count": null,
204+
"execution_count": 12,
205205
"source": [
206206
"a = (7, 3)\r\n",
207207
"b = (8,3,9)\r\n",
208208
"c = (7,3)\r\n",
209209
"print(a==b)\r\n",
210210
"print(a ==c) "
211211
],
212-
"outputs": [],
212+
"outputs": [
213+
{
214+
"output_type": "stream",
215+
"name": "stdout",
216+
"text": [
217+
"False\n",
218+
"True\n"
219+
]
220+
}
221+
],
222+
"metadata": {}
223+
},
224+
{
225+
"cell_type": "markdown",
226+
"source": [
227+
"Modifying a tuple\r\n",
228+
"-----------------"
229+
],
230+
"metadata": {}
231+
},
232+
{
233+
"cell_type": "code",
234+
"execution_count": 14,
235+
"source": [
236+
"t1 = ('Red', 'Blue')\r\n",
237+
"print(t1[0])\r\n",
238+
"t1[0] = 'Green'"
239+
],
240+
"outputs": [
241+
{
242+
"output_type": "stream",
243+
"name": "stdout",
244+
"text": [
245+
"Red\n"
246+
]
247+
},
248+
{
249+
"output_type": "error",
250+
"ename": "TypeError",
251+
"evalue": "'tuple' object does not support item assignment",
252+
"traceback": [
253+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
254+
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
255+
"\u001b[1;32m<ipython-input-14-7b32c33cda5c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mt1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[0mval\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mt1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mt1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'Green'\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
256+
"\u001b[1;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
257+
]
258+
}
259+
],
213260
"metadata": {}
214261
}
215262
],

0 commit comments

Comments
 (0)