@@ -41,15 +41,17 @@ we add an integer to a :ref:`string <textseq>`?
4141
4242.. code-block :: ipython3
4343
44- In [1]: a = 1
45- In [2]: b = 'og'
46- In [3]: print(a + b)
47- ---------------------------------------------------------------------------
48- TypeError Traceback (most recent call last)
49- <ipython-input-3-0ae8b1612688> in <module>
50- ----> 1 print(a + b)
51-
52- TypeError: unsupported operand type(s) for +: 'int' and 'str'
44+ In [1]: a = 1
45+
46+ In [2]: b = 'og'
47+
48+ In [3]: print(a + b)
49+ --------------------------------------------------------------------------
50+ TypeError Traceback (most recent call last)
51+ Cell In [3], line 1
52+ ----> 1 print(a + b)
53+
54+ TypeError: unsupported operand type(s) for +: 'int' and 'str'
5355
5456 In this error, Python is complaining that `+ ` does not make sense if
5557the items being added (the :term: `operands `) are an integer and a
@@ -62,15 +64,17 @@ also in trouble:
6264
6365.. code-block :: ipython3
6466
65- In [1]: a = {1, 2}
66- In [2]: b = {2, 3}
67- In [3]: print(a + b)
68- ---------------------------------------------------------------------------
69- TypeError Traceback (most recent call last)
70- <ipython-input-3-0ae8b1612688> in <module>
71- ----> 1 print(a + b)
72-
73- TypeError: unsupported operand type(s) for +: 'set' and 'set'
67+ In [1]: a = {1, 2}
68+
69+ In [2]: b = {2, 3}
70+
71+ In [3]: print(a + b)
72+ --------------------------------------------------------------------------
73+ TypeError Traceback (most recent call last)
74+ Cell In [3], line 1
75+ ----> 1 print(a + b)
76+
77+ TypeError: unsupported operand type(s) for +: 'set' and 'set'
7478
7579 Conversely we might suspect that two values can be added only if they are of the same
7680type. However it is perfectly legal to add an integer and a :ref: `floating
@@ -700,9 +704,9 @@ Let's try our new addition functionality in action:
700704 x^3 + 2x + 2
701705
702706 In [8]: print(1 + a)
703- ---------------------------------------------------------------------------
704- TypeError Traceback (most recent call last)
705- <ipython-input-8-a42ff1c9a542> in <module>
707+ --------------------------------------------------------------------------
708+ TypeError Traceback (most recent call last)
709+ Cell In [8], line 1
706710 ----> 1 print(1 + a)
707711
708712 TypeError: unsupported operand type(s) for +: 'int' and 'Polynomial'
0 commit comments