my question here:Hi all.The FirstClass alone works well. But when I add the SecondClass pyCharm gives me an error Here is the output,at first:
Try to have tagged code:
Output:USING CLASS
King Arthur
3.14159
New valueError:Traceback (most recent call last):
File "/home/sylvain/PycharmProjects/Py3/file3.py", line 23, in <module>
class SecondClass(FistClass):
NameError: name 'FistClass' is not defined
Process finished with exit code 1# file.3.pyprint("USING CLASS")
class FirstClass:
def setdata(self, value):
self.data = value
def display(self):
print(self.data)
x = FirstClass()
y = FirstClass()
x.setdata("King Arthur")
y.setdata(3.14159)
x.display()
y.display()
x.data = "New value"
x.display()
x.anothername = "spam"
class SecondClass(FistClass):
def display(self):
print('Current value = "%"' % self.data)
z = SecondClass()
z.setdata(42)
z.display()my code here
Try to have tagged code:
# file.3.py
print("USING CLASS")
class FirstClass:
def setdata(self, value):
self.data = value
def display(self):
print(self.data)
x = FirstClass()
y = FirstClass()
x.setdata("King Arthur")
y.setdata(3.14159)
x.display()
y.display()
x.data = "New value"
x.display()
x.anothername = "spam"
class SecondClass(FistClass):
def display(self):
print('Current value = "%"' % self.data)
z = SecondClass()
z.setdata(42)
z.display()User has been warned for this post. Reason: code/error tags, meaningless title
