Hello everyone,
i have been coding for a while and recently i have been exploring lists. One of the projects i'm doing is one that converts an input of: x_coordinate,y_coordinate;x_coordinate,y_coordinate/y_intercept into slope intercept form. Everything was going smoothly until i used the def function and i got an invalid syntax error:
def check_divs(): <----- this is the line with the syntax error
for value in range(2,9):
y_split = str(y_slope / value).split(".")
x_split = str(x_slope / value).split(".")
if y_split[1] and x_split[1] == "0":
y_slope and x_slope /= value
break
(note y_slope is the difference between the first and second set of coordinates, x_slope is the same but for the x coords)
now correct me if i am wrong, but the denoted line is not an invalid syntax. but wait, it gets weirder. i decided to temporally delete that function as i wanted to test the other parts of the code before getting into the rabbit hole of debugging. note: i had actually tested and run this portion of the code several times without an error and i had not edited it since the last time it ran smoothly. (bb refers to the y int and isn't overly important)
if coords_dec[1] == "0": <-----got the error here, coords_dec[1] is just the decimal when y_slope is divided by x_slope
print(f"y = {int(y_slope / x_slope)}x + {bb}")
else:
check_divs()
if y_slope and x_slope < 0:
print(f"y = {y_slope * -1}/{x_slope * -1}x + {bb}")
else:
print(f"y = {y_slope}/{x_slope}x + {bb}")
anyway, if someone could tell me what the heck is going on that would be great. thanks a metric TON in advanced, and have a great day!!!