Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

LoveMathFermat Group Title

Hi fellow OCW students, I have a question about problem 2 on problem set 9 of 6.00 intro to computer science and programming. 1) I have no idea what I should do for def__iter__(self) part. I think I don't know what the iterator does in a class or sth. 2) http://paste.bradleygill.com/index.php?paste_id=3786 I get a error message after spitting out the right result as follows: Traceback (most recent call last): File "<pyshell#6>", line 1, in <module> str(pj) TypeError: __str__ returned non-string (type NoneType) What did I do wrong here?

  • one year ago
  • one year ago

  • This Question is Closed
  1. slotema Group Title
    Best Response
    You've already chosen the best response.
    Medals 0

    1) I don't know that mutch about the __iter__ method. You could try to see if you understand http://docs.python.org/2/library/stdtypes.html#iterator-types 2) The __str__ method expects you to return a string as the result of the method. You don't return anything, but you print directly. Try writing all the strings you now print into a variable. At the end of the method, you can return that variable. You shouldn't need to print anything yourself.

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.