"David Grenier" <grenieda at hotmail.com> writes: Change this: > while type(champ)=='instance': to: while isinstance(champ, cons): The problem is that type(champ) doesn't return a string, so your test always is false.