Skip to content
Advertisement

assert menu.__str__() == “” AssertionError

I get assertion error when i try to assert “” (empty string) into str function. Could anyone enlighten me as of why that happens. Totally clueless here. I know the str function needs to return a string but as far as i know it is returning a string when i run:

The error comes when i run:

JavaScript

here is my code:

JavaScript

Advertisement

Answer

As the declaration is def __str__(self): you need to call it like

JavaScript

Or using str method

JavaScript

Also you have a for loop, that includes another loop on the same a_list. A good implementation is

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement