I am attempting to write a code where I pull in data from a file, formatted "3 15 0" "5 20 0" etc, where 0 denotes the end of a line and I want to convert the other numbers into denominators. I've stripped the line, gotten rid of the zeros, written a for loop that accesses each of the numbers...but I'm running into a problem with the fractions function, where it isn't importing the fraction module. I'm running 2.7, I'm not sure if that gives any insight. Thanks much.
Code:from fractions import Fraction def main(): inFile = open("data.in", "r") inFile = inFile.readlines() i = 0 for line in inFile: line = line[:-1] line = line.split() print(line) length = len(line) for x in range(length-1): var= (int(line[x])) print (Fraction(1, var)) main()