Exercise 5: str vs repr — Possible Solution ==================================================================== values = ["7", 7, "seven", 7.0, None, True] print(f"{'str':<8}{'repr':<10}{'type'}") print("-" * 30) for v in values: print(f"{v!s:<8}{v!r:<10}{type(v).__name__}") Output: str repr type ------------------------------ 7 '7' str 7 7 int seven 'seven' str 7.0 7.0 float None None NoneType True True bool WHY THIS WORKS AS AN ANSWER ------------------------------ !s asks for the everyday text of a value and !r for its code-style form, and the colon after it still takes the usual alignment spec, so {v!r:<10} means repr, left-aligned in 10 characters. The first two rows show the point of the exercise: the string '7' and the integer 7 look identical under str but different under repr, where the string gets quotes. This is also the reason print(['a']) shows quotes, because printing a collection uses repr for the items inside it.