For this lab, let’s use VSCode on Kali. (Not sure how to install it. Click Here)
Passing in command line arguments to a Python program is something you’ll commonly see and find helpful to include in your programs. Up to this point, we’ve been creating Python programs and running them like this:
python3 myprogram.py
Command line arguments are extra parameters that can be passed into a program at run time. It might look like this if we passed two command line arguments to the hypothetical program above.

In this lab, we’ll create a program that lets the end user pass values to a program. Create a folder called Lab08, and let’s call the program lab08.py. We’ll start by writing a program designed to analyze the parameters passed in by the end user.

Run the program like this, and you’ll see that it prints back the user-supplied arguments.

Just for demonstration purposes, modify/simplify the program so it now looks like this:

Now run it and consider the output:
- In the terminal at the bottom of VSCode, be sure you are in your
Lab_08 folder.
python3 Lab_08.py blue red green

Here’s the concept:
- The first value in the list
(sys.argv[0]) will always be the program name
- The second value and beyond will contain whatever the user typed in, separated by spaces
(sys.argv[1]) is the first argument passed to the program (blue)
(sys.argv[2]) is the second argument passed to the program (red)
(sys.argv[3]) is the third argument passed to the program (green)
Checkpoint/Challenge: