python how to declare global variables code example Example 1: how to declare global variable in python global n n = 'whatever' Example 2: global variables python global x x=1