Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for python - modifying an item inside an array using a function

Current License: CC BY-SA 4.0

Post Revisions

9 events
when toggle format what by license comment
Jan 25, 2022 at 17:22 history edited Jerry Stratton
The "basic" tag is for Beginners’ All-purpose Symbolic Instruction Code.
Jan 20, 2022 at 7:06 answer added SHYAM SHEEL timeline score: 0
Jan 20, 2022 at 7:06 vote accept Aks
Jan 20, 2022 at 5:57 answer added Grismar timeline score: 1
Jan 20, 2022 at 5:48 comment added Grismar arr is modified in the function, but since item is a simple immutable integer, it can't be modified inside the function, unless you declare item a global and that's not really what you want. (in fact, your code would be improved if you called a function main() or whatever from the if __name__ section, instead of having the code in there, to avoid all the variable getting declared there effectively becoming globals.)
Jan 20, 2022 at 5:46 comment added buran Not related to your question but check "Least Astonishment" and the Mutable Default Argument about using mutable default argument
Jan 20, 2022 at 5:45 comment added Barmar Python doesn't have variable references or aliases.
Jan 20, 2022 at 5:44 comment added Barmar you can't change the value of item that way. Putting a variable into a list puts the value of variable, it doesn't put a reference to the variable itself.
Jan 20, 2022 at 5:41 history asked Aks CC BY-SA 4.0

AltStyle によって変換されたページ (->オリジナル) /