File tree Expand file tree Collapse file tree 1 file changed +3
-16
lines changed Expand file tree Collapse file tree 1 file changed +3
-16
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ That works.
13
13
14
14
```
15
15
Enter a number: 3
16
- Your number twice : 6
16
+ Your number doubled : 6
17
17
```
18
18
19
19
But that doesn't work if the user does not enter a number.
@@ -103,20 +103,6 @@ TypeError: unsupported operand type(s) for +: 'int' and 'str'
103
103
>> >
104
104
```
105
105
106
- Catching ValueError doesn' t catch TypeErrors.
107
-
108
- ```py
109
- >> > try :
110
- ... 123 + ' hello'
111
- ... except ValueError :
112
- ... print (" wrong value" )
113
- ...
114
- Traceback (most recent call last):
115
- File " <stdin>" , line 2 , in < module>
116
- TypeError : unsupported operand type (s) for + : ' int' and ' str'
117
- >> >
118
- ```
119
-
120
106
Exceptions always interrupt the code even if we catch them. Here the
121
107
print never runs because it' s after the error but inside the `try`
122
108
block. Everything after the try block runs normally.
@@ -171,7 +157,8 @@ wrong type
171
157
172
158
Seems to be working.
173
159
174
- We can catch multiple exceptions by catching a tuple of exceptions:
160
+ We can also also catch multiple exceptions by catching
161
+ [a tuple ](lists- and - tuples.md# tuples) of exceptions:
175
162
176
163
```py
177
164
>> > try :
You can’t perform that action at this time.
0 commit comments