<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">only the first topic is printed. If topics only contain a single topic I get this error:</div>


Traceback (most recent call last):<br>
  File "C:\Users\fencer\workspace\Find Expert\src\find_expert.py", line 57, in <module><br>
    print experts[1]<br>
  File "C:\Users\fencer\workspace\Find Expert\src\find_expert.py", line 21, in __str__<br>
    output += '\nKnown topics: %s' % (', '.join([str(x) for x in self.topics]))<br>
TypeError: iteration over non-sequence<br>
<br>
What did I do wrong?<br><font color="#888888">
</font></blockquote><div><br></div><div>It looks like, "if topics contains only a single topic", means:</div><div><br></div><div>    self.topics = MyTopic</div><div><br></div><div>was done at some point. What you should do is make self.topics ALWAYS be a list: even if it's only a list of one item.</div>

<div><br></div><div>So you do</div><div><br></div><div>    self.topics.append(MyTopic)</div><div><br></div><div>when you add that one topic. That way self.topics is always a list. Sometimes empty, sometimes containing one element, sometimes containing many.</div>

<div><br></div><div>--S</div></div>