Import sys module

what is the meaning of sys.argv here and why are we equating it to the input and output file.

hey @sankalparora5 ,
there are many times when we need to run our code directly using cmd and also we are not taking any input from the user ( not to use input() in between code) .
So take an example like the one you are working on, you need to directly run your code from cmd using python executable file.
You write command as : ,

python file.py input.txt output.txt

So we use sys module which has a method to read parameters or arguments from the cmd command ,
so now if we print sys.argv we get output as :

[ ‘file.py’ ,“input.txt” ,‘output.txt’ ] #everything we have provided after our python code filename.

as you see sys.argv[1] refers to the input file name and sys.argv[2] refers to output file name . There fore we have have used them as such.

I hope this would have resolved your doubt.
Thank You and Happy Coding :slightly_smiling_face:.