python run javascript

Solutions on MaxInterview for python run javascript by the best coders in the world

showing results for - "python run javascript"
Luana
13 Jun 2018
1import js2py
2
3js = """
4function escramble_758(){
5var a,b,c
6a='+1 '
7b='84-'
8a+='425-'
9b+='7450'
10c='9'
11document.write(a+c+b)
12}
13escramble_758()
14""".replace("document.write", "return ")
15
16result = js2py.eval_js(js)  # executing JavaScript and converting the result to python string 
17
Ida
04 Jul 2019
1class Solution:
2    def solve(self, s):
3        x = ""
4        for i in s:
5            if i >= 'a' and i <= 'z':
6                x += i
7        i, j = 0, len(x) - 1
8        while i <= j:
9            if x[i] != x[j]:
10                return False
11            i += 1
12            j -= 1
13        return True