Reverse Pattern In Python Using Global Variables