4 ms·
"Now if you are raging to some serious dubstep, its easy enough to miss that small typo, you go screw it and do it live, and deploy to production. Python will s
by j_baker 15y ago
"Now if you are raging to some serious dubstep, its easy enough to miss that small typo, you go screw it and do it live, and deploy to production. Python will simply create the new variable and not a single thing will be said."
Erm... Did the author test this code before making this assertion?
>>> def get_first_problem(problems):
... for problem in problems:
... return problam
...
>>> get_first_problem([1,2,3])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 3, in get_first_problem
NameError: global name 'problam' is not defined
- googletron 15y agoI think it might be a typo; the return doesn't seem to like returning variables that aren't assigned values.
- dcosson 15y agomaybe he updated it? now it shows is an additional line: def get_first_problem(problems): for problem in problems: problam = problem + 1 return problam but there's nothing wrong with this, I assume he meant to return problem instead of problam which would produce an unexpected result without having added 1. Nothing a unit test wouldn't catch though :) Edit: formatting
- lucisferre 15y agoOnly you can prevent people from listening to dubstep.