I need the output of the following code to be printed in a text file. So far it creates the text file, but it does not print anything in it. Any help would be appreciated.
def findSlope (x1, y1, x2, y2):
rise = y2 - y1
run = x2 - x1
if run == 0:
slope = "undefined"
else:
slope = rise/run
return slope
import sys, string
inFile = open("C:\Python\coordinates1.txt", "r")
outFile = open("exercise1.txt", "w")
lines = inFile.readlines()
for i in inFile:
origin = i.split(',')
j=0
for j in range(len(origin)):
origin[j] = str.strip(str(origin[j]), "\n")
inFile2 = open("C:\Python\coordinates1.txt", "r")
outFile2 = open("exercise1.txt", "w")
outFile2.write(str)
outFile2.close()
print
for k in inFile2:
if k!=i:
destination = k.split(',')
e=0
for e in range(len(destination)):
destination[e] = str.strip(str(destination[e]), "\n")
print origin
print destination
print findSlope(int(origin[1]), int(destination[1]), int(origin[2]), int(destination[2]))
inFile2.close()
outFile2.close()
inFile.close()
outFile.close()