From dc42010f0b5dedb36fead4d72df824a173eb138f Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Mon, 14 Feb 2022 15:33:53 +0300 Subject: [PATCH] mklines: find intercept of last line in a list Signed-off-by: HeshamTB --- mklines.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mklines.py b/mklines.py index 85c049b..d474d08 100644 --- a/mklines.py +++ b/mklines.py @@ -31,8 +31,13 @@ def main(): print('line ', line.get_m(), line.get_b()) intercepts = list() for i, line in enumerate(lines): - if i == len(lines) - 1: break # Last line is a special case - p = lines[i].intercept(lines[i+1]) + p = None # This is risky + if i == len(lines) - 1: + print("last") + p = lines[i].intercept(lines[0]) + # Last line is a special case + else: + p = lines[i].intercept(lines[i+1]) print(p.get_x(), p.get_y()) return 0