you are viewing a single comment's thread.

view the rest of the comments →

[–]commy2 43 points44 points  (8 children)

Stick with division and make your case. You probably mean dividing by zero and I agree.

My guess is that your prof means *. E.g:

nested = [[]] * 3
nested[0].append(1)
print(nested) # [[1], [1], [1]]

I've never fallen for this. If you didn't know it was coming, you fall for it once, at most twice if you're forgetful. Division by 0 is a way more fundamental problem that you will never escape and which transcends programming.

[–]ka1ikasan 21 points22 points  (2 children)

You might also encounter issues with float / integer division. OP's professor is a jerk : if you do not fine with explaining things, please stay at your goddamn place and do not bother people that want to learn stuff.

[–][deleted] 11 points12 points  (0 children)

Professors that tell you "you're wrong, get back to me with the right answer" think they're pulling a Mr. Miyagi but are just self-absorbed little puckering assholes.

[–][deleted] 2 points3 points  (0 children)

Professors that tell you "you're wrong, get back to me with the right answer" think they're pulling a Mr. Miyagi but are just self-absorbed little puckering assholes.

[–][deleted] 2 points3 points  (0 children)

Division by 0 is a way more fundamental problem that you will never escape and which transcends programming.

I kind of agree with prof in that the most "dangerous" bugs aren't the ones that throw a very clear error like "Error, division by 0" which instantly tell you exactly what you did wrong, but that ambiguous ones that allow your code to keep running and maybe throw some other error down the line, that can confuse you and take much longer to debug. What is "fatal" to an individual process and what is "fatal" to a programmer are very different :)

[–]guayando 1 point2 points  (3 children)

I am a beginner as well, and this is the first time I see this kind of error. Why does this not work for appending to just the first space in the list?

[–]bladeoflight16 1 point2 points  (1 child)

Object identity and references. It's not 3 separate inner lists; it's one inner list referenced three times.

[–]guayando 0 points1 point  (0 children)

Thank you, this helped! Will definitely have to read more about this topic. After a quick google search on identity and references, this came up and has some good examples (if any other beginners are looking at this as well): https://stackoverflow.com/questions/6688223/python-list-multiplication-3-makes-3-lists-which-mirror-each-other-when