+ 1

why isnt awesomeinc_companies also listed in dir printed at last

(even though the condition given in func is true) https://code.sololearn.com/cDhpkeO1D6Lj/?ref=app

16th Dec 2019, 9:17 PM
PRO
PRO - avatar
2 Antworten
0
awesomeinc_companies is a local variable, that belongs to the function, and it only exists when the function is being run. Same case with the year variable, did you forget that it also doesn't exist in the dir() call ?
16th Dec 2019, 9:27 PM
Aymane Boukrouh
Aymane Boukrouh - avatar
0
If you call print (dir ()) in the 2070 if statement, it will show awesome Inc and year in the list. Those are local to that block, and not to the entire script, or global scope.
17th Dec 2019, 4:19 AM
August Borne
August Borne - avatar