Search code examples
pythonclassinheritancesubclass

does anyone know much about python class? and its objects is giving me errors when i input some data


built a class i get this error when i run the code

if unit == 'F': self.number = (number - 32) * 5/9 UnboundLocalError: local variable 'number' referenced before assignment


Solution

  • number variable need to be declare first at the beginning of to() function. A simple : " number; " in first line of your to() function will solve the problem.