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