| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 11d4006 commit 6bdb1ae
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,7 +140,7 @@ E AssertionError | |||
| 140 | 140 | ||
| 141 | 141 | ### **AttributeError** | |
| 142 | 142 | An `AttributeError` is raised when code (or a unit test!) tries to access the attribute of an object but that object has no such attribute. | |
| 143 | - For example, a unit test excepts a `Robot` object to have a `direction` attribute but when it tried to access `robot.direction`, it does not exist. | ||
| 143 | + For example, a unit test expects a `Robot` object to have a `direction` attribute, but when it tried to access `robot.direction`, it does not exist. | ||
| 144 | 144 | ||
| 145 | 145 | This could also indicate a typo, such as using `"Hello".lowercase()` when the correct syntax is `"Hello".lower()`. | |
| 146 | 146 | `"Hello".lowercase()` raises `AttributeError: 'str' object has no attribute 'lowercase'`. | |
@@ -242,7 +242,7 @@ E ImportError: In your 'lasagna.py' file, we can not find or import the functi | |||
| 242 | 242 | ||
| 243 | 243 | ### **IndexError** | |
| 244 | 244 | ||
| 245 | - Python raises an `IndexError` when an invalid index is used to look up a value in a list. | ||
| 245 | + Python raises an `IndexError` when an invalid index is used to look up a value in a sequence. | ||
| 246 | 246 | This often indicates the index is not computed properly and is often an off-by-one error. | |
| 247 | 247 | ||
| 248 | 248 | ||
@@ -354,11 +354,13 @@ E TypeError: can only concatenate str (not "int") to str | |||
| 354 | 354 | ||
| 355 | 355 | ### **ValueError** | |
| 356 | 356 | A `ValueError` is usually raised when an invalid value is passed to function. | |
| 357 | + | ||
| 358 | + | ||
| 357 | 359 | <details> | |
| 358 | 360 | <summary>Click here for code example</summary> | |
| 359 | 361 | ||
| 360 | 362 | ||
| 361 | - Note, real square roots only exist for position numbers. | ||
| 363 | + Note, real square roots only exist for positive numbers. | ||
| 362 | 364 | Calling `math.sqrt(-1)` will raise `ValueError: math domain error` since `-1` is not a valid value for a square root. | |
| 363 | 365 | In (mathematical) technical terms, -1 is not in the domain of square roots. | |
| 364 | 366 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments