Assignment stores the result of input in a name, but ordinary assignment is not an expression: it returns no value and cannot directly serve as a while condition. section 2.3
When rewriting an input loop, distinguish these two forms:
- while s = input(...): is invalid because ordinary assignment produces no value for while to evaluate. section 2.3
- while s := input(...): uses the walrus operator to assign the input and pass its value to while for Boolean evaluation. section 2.3
- An empty input string evaluates as False, allowing the loop to exit; the operator remains controversial because shorter code can add complexity and bugs. section 2.3
while s = input('Enter thoughts:'):
print(f'Your thoughts are: {s}')
Compare the tempting ordinary-assignment loop with the working assignment-expression version. section 2.3
while s := input('Enter thoughts:'):
print(f'Your thoughts are: {s}')
Use the walrus form when one condition must both capture input and test its value. section 2.3






