I think this answers your question, because it is like a "for each" loop.
The script below is valid in python (version 3.8):
a=[1,7,77,7777,77777,777777,7777777,765,456,345,2342,4]
if (n := len(a)) > 10:
print(f"List is too long ({n} elements, expected <= 10)")