# I'm not familiar with the walrus operator yet. It's a quite recent addition # (Python 3.8). But you can use it like this: if (n := len(a)) > 10: print(f"List is too long ({n} elements, expected <= 10)")