Do you actually want a list? Or just to print it like a list? In either case the following should work:
import urllib2
out = []
for url in ["http://stackoverflow.com/", "http://stackoverflow.com/questions/"]:
try:
connection = urllib2.urlopen(url)
out.append(connection.getcode())
connection.close()
except urllib2.HTTPError, e:
out.append(e.getcode())
print out
It just makes a list containing the codes, then prints the list.