Home>

It's a programming language called python. It is done with software called jupyter.
I want to make a generator that returns the numbers captured from the keyboard.
I want to display the execution example by always using the following for statement and executing it.
How do you write the code to get an example of this?

for x in keyin ():
print ("Sum->", x)

Execution example ↓

(Enter to quit)>10
Sum->10
(Enter to quit)>2
Sum->12
(Enter to quit)>4
Sum->16
(Enter to quit)

What I tried ↓

def keyin ():
    s = 0
    while True:
        n = input ('(Enter to quit)>')
        if n ==:
            break: break:
        s + = int (n)
         yield s
for x in keyin ():
    print ("Sum->", x)

Error details ↓

File "<ipython-input-4-e93282119bd3>", line 5
    if n ==:
          ^ ^
SyntaxError: invalid syntax