I've started learning Python (again). This simple code with a cycle works by itself. But when I put it into a Brython it doesn't. No part of it works until I comment out everything, but simple alert() commands. I've tried just a "i+=1" cycle — doesn't work. I've checked indents and spacing, too.
What is wrong?
Thank you.
from browser import document
from browser import alert
i=0
r = ''
s = 'nín'
d = {'nín':'нин','hǎo':'хао','lǎo':'лао','wài':'уай','ī': 'ӣ', 'bī': 'бӣ', 'jī': 'чжӣ', 'nī': 'нӣ', 'nīn': 'нӣнь', 'nīng': 'нӣн'}
def set_r():
r = '12345'
alert(i)
#while i < len(s):
#flag = True
#for j in range(4):
#t = s[i:i+j]
#if t in d:
#r += d[t]
#i += j
#flag = False
#break
#if flag:
#r += s[i]
#i += 1
alert( s );
set_r();
I wanted any part of the Python code to work in the browser, like a simple cycle with an integer.