Bugs with no error
Read · 1 of 3
No error doesn't mean no bug
A crash is a gift: it tells you where to look. A wrong answer with no error can sit in code for months.
The usual suspects: returning too early from a loop, two names that point at the same list, and conditions that are slightly off.
Read this lesson as text
Wrong answers with no crash: the dangerous kind.
No error doesn't mean no bug
A crash is a gift: it tells you where to look. A wrong answer with no error can sit in code for months.
The usual suspects: returning too early from a loop, two names that point at the same list, and conditions that are slightly off.
Exercise: Returns too soon
has_negative should say whether any number is negative.
Exercise: All the rows at once
This should print an n × n grid with 1 on the diagonal and 0 everywhere else.