Skip to content
Advertisement

Printing issues when moving from Python 2 to 3 with code

I have a code that I am trying to convert but it’s written in Python 2 and I would like to print this code in Python 3. However, it’s not able to print in matrix format. I am getting output in an unrecognizable table format.

The code is following:

JavaScript

The expected output is in the following format:

JavaScript

Could you suggest what changes I need to make in this code?

Advertisement

Answer

In py 2 print did not have parenthesis, in py3 is a must.

python3 simple print
JavaScript
python3 print with no newline / carriage return

Also in your py2 code you have print ('t'), please mind the comma after print => which means do not add a newline after print. In python3 would translate to

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement