|
232 | 232 | "IndentationError": { |
233 | 233 | "variants": [ |
234 | 234 | { |
235 | | - "title": "The indentation doesn't match", |
236 | | - "summary": "All lines in a block must start in the same column. Fix around {{loc}}.", |
237 | | - "why": "Python groups code by indentation. Mixing tabs and spaces or uneven indents breaks the block.", |
| 235 | + "title": "The indentation isn't right here", |
| 236 | + "summary": "Python uses the spaces at the start of a line to group code into blocks, and the spacing around {{loc}} doesn't fit. A line may be indented when it shouldn't be, or missing the indentation a block needs.", |
| 237 | + "why": "Lines in the same block must start in the same column, a block only opens after a line ending in a colon (:), and a line can't be indented for no reason.", |
238 | 238 | "steps": [ |
239 | | - "Use 4 spaces per level (not tabs).", |
240 | | - "Line up all lines in the block." |
| 239 | + "If a line is indented but nothing above it ends in a colon (:), remove the extra spaces.", |
| 240 | + "If a block was expected (after a line ending in :), indent its lines by the same amount.", |
| 241 | + "Keep spacing consistent - 4 spaces per level - and don't mix tabs and spaces." |
241 | 242 | ], |
242 | 243 | "_placeholders": { |
243 | 244 | "loc": "Where the indentation problem is, eg. line 7 in main.py" |
|
251 | 252 | { |
252 | 253 | "title": "These data types don't work together", |
253 | 254 | "summary": "You're joining (concatenating) different kinds of data types. For example, a number (integer or float) and a word (string).", |
254 | | - "why": "When using + to join text and variables together the variable must have a string data type.", |
| 255 | + "why": "Python's + means 'add' for numbers and 'join' for text, so both sides have to be the same kind. It can't add a number to a piece of text.", |
255 | 256 | "steps": [ |
256 | | - "Cast the variable as a string data type.", |
257 | | - "Change the variable to the right kind: int(\"3\") or str(7)." |
| 257 | + "To join them as text, convert the number with str(...).", |
| 258 | + "To add them as numbers instead, make sure neither side is text." |
258 | 259 | ] |
259 | 260 | } |
260 | 261 | ] |
|
297 | 298 | { |
298 | 299 | "title": "This index position does not exist", |
299 | 300 | "summary": "You are trying to use an index position that does not exist. The list is not that long.", |
300 | | - "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.", |
| 301 | + "why": "Items are counted from 0. In myList = [\"A\", \"B\", \"C\"], \"A\" is at index 0, \"B\" at 1 and \"C\" at 2 - so the largest valid index is 2, and index 3 does not exist.", |
301 | 302 | "steps": [ |
302 | 303 | "Check the length with len(the_list).", |
303 | 304 | "Use an index position number smaller than len(the_list)." |
|
0 commit comments