0 votes
1 view
in Blockchain by (4.1k points)

I am a newb to python. I am running a script I got on the web :

python file.py

I get this :

File "file.py", line 293

    print json.dumps(evaluate(), indent=4)
             ^
SyntaxError: invalid syntax

I read it is related to python version, that should be some 2.7. So I downloaded pyenv. And I set the right version in the directory that contains file.py : pyenv local 2.7.10. But I still get the same error.

 

(For information, I am trying to install blockchain tool : ethereum)

1 Answer

0 votes
by (14.4k points)

What happened is, 

In Python 3.x, the print statement is changed to print functions. 

While Python 2.x will fetch expected results with print "Hello World", in Python 3.x you need to use print("Hello World")

So in your code,  

You should use print( json.dumps(evaluate(), indent=4) )

Related questions

0 votes
1 answer
asked Oct 9, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
0 votes
2 answers
asked Oct 4, 2019 in Python by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 15, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...