A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-167.py
1classV:
2def__repr__(self):return"V(1)"
3def__str__(self):return"one"
4print(f"{V()}")
5print(f"{V()!r}")
Classes
Answer & explanation
Console output
one
V(1)
Why
By default an f-string field formats its value with str(), so {V()} prints "one" via __str__. Adding the !r conversion flag forces repr() instead, so {V()!r} prints "V(1)" via __repr__. The !s, !r, and !a flags pick the conversion explicitly.