Feb-04-2020, 07:20 PM
class Robot: def introduce_self(self) print("My name is " + self.name) r1 = Robot() r1.name = "Tom" r1.color = "red" r1.weight = 30 r2 = Robot() r2.name = "Jerry" r2.color = "blue" r2.weight = 40 r1.introduce_self() r2.introduce_self()With the above code, copied from the YouTube channel of CS Dojo, I get a traceback
"name 'r1' is not defined.