print('code1')
a = [1, 2, 3, 4]
if (len(a)) > 3:
print(f"List is too long ({len(a)} elements, expected <= 3)")
print('--------------------------------')
print('code2')
a = [1, 2, 3, 4]
if (n := len(a)) > 3:
print(f"List is too long ({n} elements, expected <= 3)")
print('--------------------------------')
print('code3')
a = [1, 2, 3, 4]
n = len(a)
if n > 3:
print(f"List is too long ({n} elements, expected <= 3)")
I know code 1 is not an efficient code with respect to codes 2 and 3. But do codes 2 and 3 have the same efficiency ratio together? despite of code 2 is more cleaner thant code 3 just efficentcy?
i 've confusing about this