|
1384 | 1384 | "outputs": [], |
1385 | 1385 | "source": [ |
1386 | 1386 | "with open('test.txt', 'w') as f:\n", |
1387 | | - " " |
| 1387 | + " f.write('Writing a new line\\n')" |
1388 | 1388 | ] |
1389 | 1389 | }, |
1390 | 1390 | { |
1391 | 1391 | "cell_type": "code", |
1392 | 1392 | "execution_count": null, |
1393 | | - "id": "ee84bdc5", |
| 1393 | + "id": "7d69598c", |
1394 | 1394 | "metadata": {}, |
1395 | 1395 | "outputs": [], |
1396 | 1396 | "source": [ |
1397 | | - "TypeError: can only concatenate str (not \"int\") to tuple" |
| 1397 | + "with open('test.txt', 'a') as f:\n", |
| 1398 | + " f.write('Adding a new line to the last one\\n')" |
1398 | 1399 | ] |
1399 | | - }, |
1400 | | - { |
1401 | | - "cell_type": "code", |
1402 | | - "execution_count": 2, |
1403 | | - "id": "d196942f", |
1404 | | - "metadata": {}, |
1405 | | - "outputs": [ |
1406 | | - { |
1407 | | - "ename": "TypeError", |
1408 | | - "evalue": "can only concatenate str (not \"int\") to str", |
1409 | | - "output_type": "error", |
1410 | | - "traceback": [ |
1411 | | - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
1412 | | - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", |
1413 | | - "Input \u001b[0;32mIn [2]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m123\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m4\u001b[39;49m\n", |
1414 | | - "\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str" |
1415 | | - ] |
1416 | | - } |
1417 | | - ], |
1418 | | - "source": [ |
1419 | | - "'123' + 4" |
1420 | | - ] |
1421 | | - }, |
1422 | | - { |
1423 | | - "cell_type": "code", |
1424 | | - "execution_count": 1, |
1425 | | - "id": "7f63db06", |
1426 | | - "metadata": {}, |
1427 | | - "outputs": [ |
1428 | | - { |
1429 | | - "ename": "AttributeError", |
1430 | | - "evalue": "'tuple' object has no attribute 'append'", |
1431 | | - "output_type": "error", |
1432 | | - "traceback": [ |
1433 | | - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
1434 | | - "\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)", |
1435 | | - "Input \u001b[0;32mIn [1]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m var \u001b[38;5;241m=\u001b[39m (\u001b[38;5;241m1\u001b[39m,\u001b[38;5;241m2\u001b[39m,\u001b[38;5;241m3\u001b[39m)\n\u001b[0;32m----> 2\u001b[0m \u001b[43mvar\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mappend\u001b[49m(\u001b[38;5;241m4\u001b[39m)\n", |
1436 | | - "\u001b[0;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'append'" |
1437 | | - ] |
1438 | | - } |
1439 | | - ], |
1440 | | - "source": [ |
1441 | | - "var = (1,2,3)\n", |
1442 | | - "var.append(4)" |
1443 | | - ] |
1444 | | - }, |
1445 | | - { |
1446 | | - "cell_type": "code", |
1447 | | - "execution_count": null, |
1448 | | - "id": "4faaae64", |
1449 | | - "metadata": {}, |
1450 | | - "outputs": [], |
1451 | | - "source": [] |
1452 | 1400 | } |
1453 | 1401 | ], |
1454 | 1402 | "metadata": { |
|
0 commit comments