import urllib2 file_url = 'https://projecteuler.net/project/resources/p102_triangles.txt' fh = urllib2.urlopen(file_url) C = 0 for line in fh: ax, ay, bx, by, cx, cy = map(int, line.split(',')) a = ax*by - ay*bx > 0 b = bx*cy - by*cx > 0 c = cx*ay - cy*ax > 0 C+= a==b==c print "Number of triangles that contain the origin", C