DEV Community

Cover image for Am I wrong with the coding porting Javascript to Python
Subhan Nooriansyah
Subhan Nooriansyah

Posted on • Originally published at dev.to

Am I wrong with the coding porting Javascript to Python

Today, i have notification from inspiration @codr [Road to be Genius Superior #51 (https://dev.to/codr/road-to-genius-superior-51-2c3f). Sometimes i used to Javascript for developing web client. My focus already change from software engineering to Data Scientist or Machine Learning. So, i am trying to port javascript to python, i am already creating this gist.Okey, this is the code of Javascript.

Alt Text

The next, it is my code of python. I have tried to understand line by line and porting to syntax python.

Alt Text

I think is not quite different with Javascript but, the result is different, maybe i have missed something in python code.

Alt Text

For better known the result check the blog of @codr , or any idea about this python coding, you can comment here.

Top comments (2)

Collapse
 
valxntine profile image
valentine

I'm not at a machine so I can't test anything right now, but Pythons range() function stops BEFORE the ending number, is this an off-by-one mistake?

Collapse
 
subhanshuja profile image
Subhan Nooriansyah

yup, that rights