It would be bad practice to always assume that the arguments your function needs are available on the command line - what if this code was called in some other way?
The function must declare input parameters for the data to which it must access.
At the very least, passing the necessary argument in f()instead of accessing sys.argvhelps make it f()much more reusable.
source
share