1
You need to add the method strip(). To remove whitespace at the beginning and end of the generated strings.
A possible solution, using your code, would be:
def __repr__(self):
r = ""
pointer = self.top
while(pointer):
r = r + str(pointer.data) + " "
pointer = pointer.next
return r.strip()
This way the expected output will be equal to the response obtained from your program.
Just out of curiosity what that would be
self.top
?– Augusto Vasques
I believe the top of the stack
– user217173
Beauty is top of the stack, but that top of the stack is instance of that class?
– Augusto Vasques
class Stack:
 def __init__(self):
 self.top = None
 self._size = 0
You’re talking about the battery class?– user217173
kkkk sorry, not manjo much am paying ed for the first time
– user217173