You need to declare that weight
is global inside GetLiveWeight
, not outside it.
weight="value"
def GetLiveWeight():
global weight
The global
statement tells Python that within the scope of the GetLiveWeight
function, weight
refers to the global variable weight
, not some new local variable weight
.