Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sim_b.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Scenario B — feature work that lands first, then merge master in."""


def compute_total(items):
"""Shadows builtin 'sum'."""
sum = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

`sum` redefined as variable disables builtin `sum()`


The variable sum is assigned a value, which overwrites the builtin sum() function in this scope. This causes any call to sum() here to fail or behave unexpectedly, potentially leading to bugs.

Rename the variable to a non-builtin name like total_sum or accumulator to preserve access to the builtin sum() function and avoid confusion.

for item in items:
sum += item
return sum
Loading