Now, writing your code can introduce sometimes to a lot of retyping the same line of code over and
over again, and a very simple way to avoid that is by inheritance.
And I will show you what the problem is and how to solve it.
So let's see that we have a class that is creating German people so German and then will create a method
here speak.
And who print speaking, right?
Then our friend Marc Klaas, and this will be called French, and I will right here, T.F. speak French
speaking.
So do see where the problem is here?
Well, here you basically have the same method in the two functions.
So isn't it better to have the method defined only in the one function and then simply send in some
way with the rest of the functions?
For example, we him here for 50 more countries, then this pretty much becomes a problem because you
need to create the same method 50 times.
So, yes, there is actually an easy way to solve this, and this is by inheritance.
So if I create another class in the class will be called human and I will simply copy and paste this
in the class.
So we have it there as well.
So now since the German and the French and they're both humans and they both can speak, what you can
do is to dismantle from here and aragón the brackets human.
And this means that the German will basically get all the medals from the class human or it will inherit
them.
And this you can do when you inherit the method of the class that is higher level than yours.
So for example, your first human and then you German.
So basically the German will inherit all the features of the class from which you can see error here.
And this is because Python don't like when you don't have anything inside your class.
And for that reason you can write here pass, which basically says that you should pass this line without
the initials.
And you can see that now our error is removed.
And this is the same for the French pass and also right here.
Sure.
So now let's create a French class, for example.
Let's Steffon be a French person.
So are as different.
Of course, French.
Right.
And now if I write.
So we feel right, Stefan, and the right not after, but you can see that we are getting the speaker's
proposal, which means that we successfully inherited the Speakman.
And now let's run the code now.
And you can see that now Steffon can speak because it's heard that the method from the human plus.