# Commanding.py Copyright (c) Kari Laitinen # http://www.naturalprogramming.com # 2006-05-23 File created. # 2022-12-16 Converted to Python 3. # Command line parameters are often called command line arguments. import sys # needed when command line parameters are used command_line_parameters = sys.argv[ 1 : ] print( "\n This program was given the following %d strings" \ "\n as command line parameters:" % len( command_line_parameters ) ) parameter_index = 0 while parameter_index < len( command_line_parameters ) : print( "\n " + command_line_parameters[ parameter_index ], end=" " ) parameter_index += 1 # The following are sample runs of this program: # #D:\pythonfiles2>\Python24\python Commanding.py # # This program was given the following 0 strings # as command line parameters: # #D:\pythonfiles2>\Python24\python Commanding.py Hello program, how are you? # # This program was given the following 5 strings # as command line parameters: # # Hello # program, # how # are # you?