I'm trying to do what should be simple string comparison, but I can't get it to work:
class Bonk:
def __init__(self, thing):
self.thing = thing
def test(self):
if self.thing == 'flarn':
return 'you have flarn'
return 'you have nothing'
bonk1 = Bonk('glurm')
bonk2 = Bonk('flarn')
bonk1.test()
bonk2.test()
This returns nothing. I've tried this too:
def test(self):
if self.thing in ['flarn']:
...
and that doesn't work either.
I've tried double quotes, assigning 'flarn' to a variable and then testing against the variable, adding a comma at the end of the list test. I tried passing it in as a variable instead... but nothing is working.
What am I missing?
Aucun commentaire:
Enregistrer un commentaire