while loop - Python Curiosity -


i curious how program reads. have foo functions top. "thing" global variable. sets "thing" equals 100 "item" equals 100. return "item" == 0 not sure about. "item" equal 0? going down flag = false. "when not flag:" called, asks users input , whatever reason until enter "0" flag turns true , "thing" equals 0. if can explain how works appreciate it

def foo(item):     global thing     thing = item     return item == 0  thing = 100 flag = false while not flag:     flag = foo(int(input("give me want here: "))) print(thing) 

item set whatever user responded when prompted give me want here, converted integer. in turn thing set value (thing = item binds global thing whatever item points at).

so if user enters 0, item set 0, thing set 0 , item == 0 returns true, ending while loop.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -