# call len(a) once n = len(a) if n > 10: print(f'list too long, {n} elements')
# call len(a) once and assign it to x # needs parenthesis, := piority lower than other operator if (x := len(a)) > 10: print(f'list too long, {x} elements') print(f'list too long, {x} elements')
scanrio 2: while loop
read a string flow till the end.
1 2 3 4 5 6 7 8 9 10 11
# basic f1 = io.StringIO('123456789') x1 = f1.read(2) while x1: print(x1) x1 = f1.read(2)