How to solve “SyntaxError: unexpected EOF” error in python?

+2 votes

I am trying to parse blockchain using python using the following code:

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))

I am getting this following error:

File "<ipython-input-3-06037b89d550>", line 1

    for block in iter_blocks():

                               ^

SyntaxError: unexpected EOF while parsing

I have checked the code from my reference and there is no problem in the code but it is still not working. How to solve this?

Jul 29, 2018 in Blockchain by digger
• 27,620 points
483 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+2 votes
Best answer

There is not a problem in the code but there is a problem in the indentation.

Use the code with proper indentation like this:

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))

This should solve your error

answered Jul 29, 2018 by slayer
• 29,040 points

selected May 5 by Omkar

I am getting the same error for this code:

name ='John'
friend = 'Sharon'
print('Hello %s, this is %s' % (name, friend)

You are missing a parenthesis in your code. The proper code would be:

print('Hello %s, this is %s' % (name, friend))

Related Questions In Blockchain

0 votes
1 answer

How to solve EACCES:permission denied error in Hyperledger Composer?

It seems like there is no required ...READ MORE

answered Jul 11, 2018 in Blockchain by digger
• 27,620 points
216 views
0 votes
1 answer
0 votes
1 answer

How to solve Runtime error when querying Hyperledger?

OCI is open container initiative.. The error ...READ MORE

answered Jul 9, 2018 in Blockchain by slayer
• 29,040 points
176 views
0 votes
1 answer
0 votes
1 answer

Invalid Batch or signature in Savtooth

This will solve your problem import org.apache.commons.codec.binary.Hex; Transaction txn ...READ MORE

answered Aug 1, 2018 in Blockchain by digger
• 27,620 points
37 views
+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,040 points
486 views
0 votes
1 answer

How to solve "error trying install composer runtime" in Hyperledger composer?

I think the docker-compose tool is not ...READ MORE

answered Jul 17, 2018 in Blockchain by slayer
• 29,040 points
51 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.