We are working on a project where we are translating javaScript code into python. Everything is going pretty smoothly, except for this one line of code that has given us errors on multiple translations:
"primes" is an empty array BTW.
JavaScript:
var primes = [];
if(primes[primes.length - 1] > 3){...}
Python:
primes = []
if primes[len(primes) - 1] > 3:
......
This code works in javascript, however in Python we get an error. It seems as though we are trying to access an index of the list that doesn't exist.
This is the error:
TypeError: object of type 'int' has no len()
Does anyone have a workaround?