Exercise 8: Average of Numbers Until a Blank Line — Possible Solution ==================================================================== total = 0.0 count = 0 while (text := input("Number (blank to finish): ")) != "": total += float(text) count += 1 if count == 0: print("No numbers entered") else: print(f"Average of {count} numbers: {total / count:.2f}") Example run: Number (blank to finish): 4 Number (blank to finish): 8 Number (blank to finish): 6 Number (blank to finish): Average of 3 numbers: 6.00 Second run: blank straight away: Number (blank to finish): No numbers entered WHY THIS WORKS AS AN ANSWER ------------------------------ The condition does two jobs in one line: input() reads a line, := stores it in text, and the comparison with the empty string decides whether to go round again. Without the walrus operator you would need one input() before the loop and a second at the end of the body, repeating the same prompt in two places. The brackets around text := input(...) are required. After the loop the count == 0 test protects the division: pressing Enter straight away would otherwise cause a ZeroDivisionError.