|
15 | 15 | "fallbackWhy": "The last line of the trace tells you the error type and main cause.", |
16 | 16 | "fallbackStep": "Try a fix and run again." |
17 | 17 | }, |
18 | | - "glossary": { |
19 | | - "kid": { |
20 | | - "variable": "name", |
21 | | - "function": "recipe", |
22 | | - "object": "thing" |
23 | | - } |
24 | | - }, |
25 | 18 | "errors": { |
26 | 19 | "NameError": { |
27 | 20 | "variants": [ |
28 | 21 | { |
29 | | - "title": "This name doesn't exist yet", |
30 | | - "summary": "Your code uses \"{{name}}\", but it hasn't been created yet. Check {{loc}}. If you meant the text <i>{{name}}</i>, put it in double quotes.", |
31 | | - "why": "Python needs to see a line that creates \"{{name}}\" before you use it.", |
| 22 | + "title": "This variable doesn't exist yet", |
| 23 | + "summary": "Your code uses the variable \"{{name}}\", but it hasn't been created yet. Check {{loc}}. If you meant to print the text <i>{{name}}</i>, put it in double quotes.", |
| 24 | + "why": "Without speech marks Python treats <i>{{name}}</i> as a variable, and this variable does not exist yet.", |
32 | 25 | "steps": [ |
33 | | - "Make it first (for example: {{name}} = 0).", |
| 26 | + "If it is meant to be text put speech marks around {{name}}.", |
| 27 | + "If it is meant to be a variable make it first (for example: {{name}} = 0).", |
34 | 28 | "Check spelling and capital letters." |
35 | 29 | ] |
36 | 30 | }, |
37 | 31 | { |
38 | 32 | "if": { |
39 | 33 | "match_message": ["is not defined"] |
40 | 34 | }, |
41 | | - "title": "This name doesn't exist here", |
| 35 | + "title": "This variable doesn't exist here", |
42 | 36 | "summary": "\"{{name}}\" might be created somewhere else, but you're using it at {{loc}}. If you meant the text <i>{{name}}</i>, put it in double quotes.", |
43 | | - "why": "A name created in another place might not be available here.", |
| 37 | + "why": "A variable created in another place might not be available here.", |
44 | 38 | "steps": [ |
45 | 39 | "Move the line that makes it to above where you use it.", |
46 | 40 | "Or set it here just before you use it." |
|
52 | 46 | "UnboundLocalError": { |
53 | 47 | "variants": [ |
54 | 48 | { |
55 | | - "title": "Used before it gets a value in this part of the code", |
| 49 | + "title": "Variable used before it gets a value in this part of the code", |
56 | 50 | "summary": "Here, \"{{name}}\" is used at {{loc}} before you give it a value.", |
57 | | - "why": "Because you assign to this name in this part, Python treats it as local here. It is read before you set it.", |
| 51 | + "why": "You have used the variable before it has been given a value. If used within a subroutine, the variable must either be global and given a value outside the subroutine definition, or local and given a value inside the subroutine, before it is used. ", |
58 | 52 | "steps": [ |
59 | | - "Give it a value first (add a line like {{name}} = ... before you use it).", |
60 | | - "If you meant a different value, use a different name here." |
| 53 | + "Give it a value first (add a line like {{name}} = ... before you use it)." |
61 | 54 | ] |
62 | 55 | } |
63 | 56 | ] |
|
71 | 64 | "not_code": [":\\s*$"] |
72 | 65 | }, |
73 | 66 | "title": "Missing colon (:) at the end", |
74 | | - "summary": "This line starts a block and needs a colon at {{loc}}: {{codeLine}}", |
75 | | - "why": "In Python, lines that start a block must end with a colon.", |
| 67 | + "summary": "There is a colon (:) missing at the end of a line. Check {{loc}}: {{codeLine}}", |
| 68 | + "why": "In Python constructs like if statements, for loops and while loops must have a colon at the end of their first line.", |
76 | 69 | "steps": [ |
77 | 70 | "Add a colon (:) at the end of that line." |
78 | 71 | ] |
|
107 | 100 | "TypeError": { |
108 | 101 | "variants": [ |
109 | 102 | { |
110 | | - "title": "These values don't work together", |
111 | | - "summary": "You're combining different kinds of values (for example, a number and a word).", |
112 | | - "why": "Operators like + only work with certain kinds together.", |
| 103 | + "title": "These data types don't work together", |
| 104 | + "summary": "You're joining (concatenating) different kinds of data types. For example, a number (integer or float) and a word (string).", |
| 105 | + "why": "When using + to join text and variables together the variable must have a string data type.", |
113 | 106 | "steps": [ |
114 | | - "Change a value to the right kind: int(\"3\") or str(7).", |
115 | | - "Use an operator that works with these values." |
| 107 | + "Cast the variable as a string data type.", |
| 108 | + "Change the variable to the right kind: int(\"3\") or str(7)." |
116 | 109 | ] |
117 | 110 | } |
118 | 111 | ] |
|
148 | 141 | "IndexError": { |
149 | 142 | "variants": [ |
150 | 143 | { |
151 | | - "title": "That position is outside the list", |
152 | | - "summary": "You're asking for a list position that isn't there.", |
153 | | - "why": "List positions start at 0 and stop before the list's length.", |
| 144 | + "title": "This index position does not exist", |
| 145 | + "summary": "You are trying to use an index position that does not exist. The list is not that long.", |
| 146 | + "why": "In this list: myList[\"A\", \"B\", \"C\"] \"A\" has the index position 0, \"B\" has the index position 1 and \"C\" has the index position 2. Index position 3 does not exist.", |
154 | 147 | "steps": [ |
155 | 148 | "Check the length with len(the_list).", |
156 | | - "Use a position number smaller than len(the_list)." |
| 149 | + "Use an index position number smaller than len(the_list)." |
157 | 150 | ] |
158 | 151 | } |
159 | 152 | ] |
|
167 | 160 | "why": "The dictionary has no value for that key.", |
168 | 161 | "steps": [ |
169 | 162 | "Check the exact key (spelling and capital letters).", |
170 | | - "If it might be missing, use dictionary.get(key, default) or add the key first." |
| 163 | + "It might be missing, use dictionary.get(key, default) or add the key." |
| 164 | + ] |
| 165 | + } |
| 166 | + ] |
| 167 | + }, |
| 168 | + |
| 169 | + "ZeroDivisionError": { |
| 170 | + "variants": [ |
| 171 | + { |
| 172 | + "title": "You can't divide by zero", |
| 173 | + "summary": "You are trying to divide a number by zero, which is not possible.", |
| 174 | + "why": "In mathematics, division by zero is undefined.", |
| 175 | + "steps": [ |
| 176 | + "Change the calculation so that you are not dividing a number by 0." |
171 | 177 | ] |
172 | 178 | } |
173 | 179 | ] |
|
0 commit comments