0
Can someone help me figure out why my test case is failing with the dunder str function?
This code is two parts from a module, I dont know how to implement modules through my phone so I condensed it to the issue I need help resolved so it won't work, not intended to through here I just wanted to clarify what I've got so far through my IDLE on my laptop and am asking for help with my dunder str function and why I cant get it to pass. https://code.sololearn.com/ccI36YD7AQbY/?ref=app
11 Answers
+ 1
try :
return f'FIRST NAME: {self.first}\nLAST NAME: {self.last}\nADDRESS: {self.address}'
+ 1
Haha, I've never had a Python teacher but i feel you nonetheless OOP is serious stuff. its all just about how you think of it. The "object" part in OOP is the biggest part! Just keep writing oop code and it'll click.
+ 1
I'll keep at it I'm getting better at it plus I watch alot of YouTube stuff too on it thanks for the help I'll figure it out eventually have a good night or day man lol
0
Tried that, it's still saying its failing. This should be easy and I feel like I'm getting closer but I can't seem to get it it.
The format for it should come out like this
FIRST NAME: Jane
LAST NAME: Doe
ADDRESS: 123 Fake St., Fakeville, FA 12345, USA
I've tried so many inputs and it's still failing
0
thats what the above code will do exactly. whats the error exactly? and how about you cut out all that test stuff for starters, clear that clutter.
you want to see it it worked? assign an instance to a variable name, then print the variable name.
0
That's the thing it's not giving me any error when I run it. It just brings up the failed person test output meaning that it's wrong that's why I'm so confused as to what's going on here.
0
it looks like your test case has to match perfectly with whatever string you put in there. it could be missing a space or something small but that shouldn't matter. what is the point of the test case?
0
It's just something I'm practicing while I'm teaching myself more about OOP. Like a challenge, should be simple but I'm stumping myself lol
0
try making the test case conditional:
if person_1.__str__() != '<the string here>':
instead of :
if str(person_1) != '<the string here>'
0
No actually I'm not being honest with you its actually an assignment from my online classes that my professor gives us but I dont like saying I need help with my assignments but then again I do at times when I'm really stumped. I wish I could show you everything I'm supposed to be doing. Hes very specific and I can figure out majority of it on my own but it's still hard to wrap my head around somethings and OOP is one of them. Wait, you sent me those pdfs awhile back right? I think I still have your email.