I am in problem4 of pset 9 and for some reason my function only ends up returning the last element instead of the whole class. This is the code I am using in the next post

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get our expert's

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions.

A community for students.

I am in problem4 of pset 9 and for some reason my function only ends up returning the last element instead of the whole class. This is the code I am using in the next post

MIT 6.00 Intro Computer Science (OCW)
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this and thousands of other questions

def readShapesFromFile(filename): """ Retrieves shape information from the given file. Creates and returns a ShapeSet with the shapes found. filename: string """ ## TO DO inputFile = open(filename) shapeD = {} group = None for line in inputFile: print 'group up', group stripped = line.strip('\n') splitted = stripped.split(',') splitted[1] = float(splitted[1]) shape = splitted[0] shape = capitalize(shape) values = splitted[1:] group = ShapeSet() if shape == 'Circle': group.addShape(Circle(values[0])) if shape == 'Square': group.addShape(Square(values[0])) if shape == 'Triangle': group.addShape(Triangle(values[0], values[1])) print 'group', group print 'group outside loop', group return group
still on ps8 but once I'm doing ps9 I'll get back to you maybe today even...
You create a new ShapeSet() in every loop iteration, thus losing whatever you've stored in it till that moment.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Thanks! I don't know what was I thinking :(
@knowak :gave you a medal ~ thought you deserved it for that one.

Not the answer you are looking for?

Search for more explanations.

Ask your own question