usethree.py


Below is the syntax highlighted version of usethree.py from §1.1 Hello World.


#-----------------------------------------------------------------------
# usethree.py
#-----------------------------------------------------------------------

import stdio
import sys

# Accept three names as command-line arguments. Write a "hi" message
# to standard output that contains the three names in reverse order.

stdio.write('Hi, ')
stdio.write(sys.argv[3])
stdio.write(', ')
stdio.write(sys.argv[2])
stdio.write(', and ')
stdio.write(sys.argv[1])
stdio.writeln('.')

#-----------------------------------------------------------------------

# python usethree.py Alice Bob Carol
# Hi, Carol, Bob, and Alice.


Copyright © 2000–2015, Robert Sedgewick, Kevin Wayne, and Robert Dondero.
Last updated: Fri Oct 20 20:45:16 EDT 2017.