0

Please does anyone has any idea why this code outputs False? It's a sololearn challenge quiz.

class Solo(): def __str__(self): return "sololearn" a = "sololearn" b = Solo() print (a == b)

13th Jun 2021, 9:44 PM
Einstein IJ
Einstein IJ - avatar
2 Answers
+ 1
This little adaption to your code might explain. class Solo(): def __str__(self): return "sololearn" a = "sololearn" b = Solo() print (a == b) print(type(a)) print(type(b)) As you can see, the outputs types are different, which creates a false result
13th Jun 2021, 10:35 PM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Rik Wittkopp, Woah thank you. Just realized that now. That's indeed a smart way of checking..
14th Jun 2021, 4:45 AM
Einstein IJ
Einstein IJ - avatar