Collecting Rich Data Structures for students

bearophileHUGS at lycos.com bearophileHUGS at lycos.com
Wed Jan 9 13:39:17 CET 2008


It may be better to keep the data in a simpler form:

data = """\
42 40 73 45 Albany, N.Y.
35 5 106 39 Albuquerque, N.M.
35 11 101 50 Amarillo, Tex.
34 14 77 57 Wilmington, N.C.
49 54 97 7 Winnipeg, Man., Can."""

cities = {}
for line in data.splitlines():
    a1, a2, a3, a4, n = line.split(" ", 4)
    cities[n] = [(int(a1), int(a2), "N"), (int(a3), int(a4), "W")]
print cities

Bye,
bearophile



More information about the Python-list mailing list