Back

Explore Courses Blog Tutorials Interview Questions
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.6k points)
0 votes
1 answer
0 votes
1 answer
asked Dec 12, 2020 in Python by laddulakshana (12.7k points)
0 votes
1 answer
asked Dec 10, 2020 in Python by laddulakshana (12.7k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94k users

Browse Categories

...