Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
inheritance
#4
keeping on with the question, why wont this code work for me using multiple inheritance:
class First():
    def number_input(self):
        self.x = int(input("whats your first number?\n"))

class Second(First):
    def result(self):
        self.z = self.x + 2
        print(self.z)

class Third(First, Second):
    def last_result(self):
        w = self.z + self.x
        print(w)

obj = Third()
obj.number_input()
obj.result()
obj.last_result()

never mind, understood i dont need to list the first class inside the second
Reply


Messages In This Thread
inheritance - by Arifattal - Jan-09-2018, 05:40 PM
RE: inheritance - by snippsat - Jan-09-2018, 07:00 PM
RE: inheritance - by Arifattal - Jan-09-2018, 07:17 PM
RE: inheritance - by Arifattal - Jan-15-2018, 02:52 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020