Jürgen K.
Jürgen K.

Reputation: 3487

SyntaxError: unexpected EOF while parsing (python blockchain)

What I'm trying to do is to iterate over all blocks in blockchain and print out the transactions. Here is my code so far:

from chainscan import iter_blocks
for block in iter_blocks():
    if block.height > 10: break
    for tx in block.txs:
        print('Hello, tx %s in block %s' % (tx, block))

The problem is that I get the following error:

  File "<ipython-input-3-06037b89d550>", line 1
    for block in iter_blocks():
                               ^
SyntaxError: unexpected EOF while parsing

I already read similar topics like: this or this, but they weren't helpful. Is the problem maybe that the blockchain itself isn't found yet by the block iterator? If it is the case, how can I solve it? Thanks in advance

Upvotes: 1

Views: 657

Answers (1)

YinYang16
YinYang16

Reputation: 471

Looks like you indentation is off. Just copy-paste the following code, and it should work:

from chainscan import iter_blocks
for block in iter_blocks():
    if block.height > 10: break
    for tx in block.txs:
        print('Hello, tx %s in block %s' % (tx, block))

Upvotes: 1

Related Questions