Aug-20-2020, 12:11 PM
Those are parameters to the function and so the names are only relevant inside the function. The variables you pass to the function containing the values for those parameters of course don't need to have the same names as those. It wouldn't really make sense to enforce that, would it?
For example, given
For example, given
>>> def foo(x, y): ... print(x, y) ...I can call all of these:
>>> z = 1 >>> t = 2 >>> foo(z, t) 1 2 >>> foo(3, 4) 3 4 >>> x = 5 >>> y = 10 >>> foo(x, y) 5 10 >>>Note that in the last example, there are two variables
x
: one local to the function and one outside it. Perhaps you need to learn about scope if you don't understand this?