How to fix UnboundLocalError: local variable 'x' referenced before assignment in Python | DevErrors