Ad
  • Default User Avatar

    I'm also getting confused. As I know changing a variable's value in a function doesn't affect the variable outside of the scope. For that we use the global command.

  • Custom User Avatar

    In this case is ok, since the parameters are integers and float numbers, so changing them inside the function will not change the value in the caller. If instead this was a list, a set, or other types that are passed as refrences then changing the value inside the function could cause side effects outside the function

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Sure. You can modify its name.

  • Default User Avatar

    Something I've seen mention of but want to confirm. Is it okay to modify a parameter passed to the function or should I be assigning its value to a new variable and modifying that. Just want to make sure I'm getting into a best practices habbit even if my code isn't very pythonic yet.