#!/usr/bin/python2.2 -u import sys import cgitb; cgitb.enable() from random import choice, shuffle sys.stderr = sys.stdout print "Content-Type: text/html\n\n" f = open('/var/www/vhosts/4dsolutions.net/cgi-bin/statecapitals.txt','rt') cities = [] states = [] for line in f: city, state = line.split(',') cities.append(city) states.append(state.strip()) f.close() print "" print "" print '
' randstate = choice(states) print "

What is the capital of %s?

" % randstate print """
" print '' print '' % randstate print "
" print "
" print "" print ""