0

I have a python function that I want to exec from bash. With Python 2 it works

$ python2 -c "import bech32; print bech32.bech32_create_checksum('tb', [0, 3] )"
[11, 18, 12, 1, 31, 6]

But I have an error syntax with python3

$ python -c "import bech32; print bech32.bech32_create_checksum('tb', ['0, 3'] )" 
  File "<string>", line 1
    import bech32; print bech32.bech32_create_checksum('tb', ['0, 3'] )
                              ^
SyntaxError: invalid syntax

my python version is:

$ python --version
Python 3.7.7
foo_bar
  • 99
  • 2
  • 8

2 Answers2

-1

Yes, it even points to the place where the error is. In python3, print is a function so should be invoked with parentheses: python3(...).

bipll
  • 11,747
  • 1
  • 18
  • 32
-1

print() is a function in Python 3, not part of syntax. That's why you need parentheses there.

EdvardM
  • 2,934
  • 1
  • 21
  • 20