In Python, global and nonlocal keywords manage variable scope within functions. They dictate whether a variable inside a function refers to a variable outside of it. Global Keyword The global keyword is used to modify a variable defined outside the current function, in the global scope. Without global, any assignment to a variable within a function is assumed to be local to that function. Nonlocal Keyword The nonlocal keyword is used in nested functions to modify a variable in the nearest enclosing scope that is not global. It allows inner functions to modify variables in the outer (non-global) function's scope