Write a program that calculates the sum of the numbers entered by the user. The program will continue until the user has not entered an empty string. (use the walrus operator in the condition).
I think all my code is wrong
summ = []
while (b := int(input('x: '))) != '':
summ.append(b)
print(sum(summ))
>Solution :
You could use an assignment expression (a.k.a. walrus operator) for your use-case like this:
summ = 0
while (b := input('x: ')):
summ += int(b)
print(summ)