Although we don't know the format of the file, this is probably a never-ending loop as you are iterating over, and appending to, the same list.
for data in citynames:
citynames.append(data[0])
Run this snippit as it limits the list to a length of 100, instead of an infinite loop.
x = [ 1, 2, 3 ]
for ctr, el in enumerate(x):
if len(x) < 100:
x.append(el)
print ctr
print x
woooee
Posting Maven
2,707 posts since Dec 2006
Reputation Points: 827
Solved Threads: 780
Skill Endorsements: 9
Using the datetime module is an easy way to subtract one time value from another IMHO.
import datetime
# subtract 10:02:59 from 12:01:02
difference = datetime.datetime(2011, 5, 11, 12, 1, 2) - \
datetime.datetime(2011, 5, 11, 10, 2, 59)
print "the difference is %s" % (str(difference))
#
# also note that split(":") is a better way to split the input
# and you can also check for len == 3
time_input = "2:03:05"
print time_input, "-->", time_input.split(":")
woooee
Posting Maven
2,707 posts since Dec 2006
Reputation Points: 827
Solved Threads: 780
Skill Endorsements: 9