0
Python: a matter of Class()
If b is "sololearn", why result is False? class Solo(): def __str__(self): return "sololearn" a = "sololearn" b = Solo() print (b) print (a==b)
2 Respuestas
+ 2
Like HonFu said a and b are two different things.
Add this 2 lines of code to see what he means:
print(type(a))
print(type(b))
+ 4
b is not the string 'sololearn', b is an instance of the class Solo.
When you try to print it, the magic method str returns the string 'sololearn'.