Why do I have keep getting index error whenever I provided less than 3 in my command line argument
2 Answers
It's much better to put the actual code instead of an image by the way.
You are trying to get index 2 (3rd item in the list) of a list that only has 2 items in it when you do second_arg = sys.argv[2]. Since the list is not that long, that is why it is throwing an error.
You may want to do your assignments after your if statement. That way you'll know that you can index that far.
sys.argv[1]andsys.argv[2]even though they aren't there.python3 fruits.py apple, you only pass 1 argument but you try to get 2nd and 3rd. If you usepython3 fruits.py apple arg2 arg3, it will not raise an error.