In python, variables that are only referenced inside a function are implicitly global. If a variable is assigned inside the function, it's considered to be a local unless it's explicitly mentioned or declared globally. This has been a major confusion as a beginner. Hope this cleared it.