-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1200
base: master
Are you sure you want to change the base?
Solution #1200
Conversation
def __init__(self, name: str) -> None: | ||
self.name = name | ||
self.skills: list[str] = [] | ||
|
||
def learn_skill(self, skill: str) -> None: | ||
if skill not in self.skills: | ||
self.skills.append(skill) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can not use if
in learn_skill
method, if you have created list in the __init__
method, because you already have this list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method __init__
creates an empty list for storing skills.
The learn_skill
method adds a new skill, but first checks if the list already contains this skill to avoid duplicates.
So, in my opinion, the verification is important.
class FrontendDeveloper(SoftwareEngineer): | ||
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills.extend(["JavaScript", "HTML", "CSS"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess, if you pass only name to patent class, you don't have skills attribute in the current instanse , and i think, you can write like this: self.skills = ["JavaScript", "HTML", "CSS"]
it is created skills
attribute in this instance
and the same in other classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The self.skills
attribute is already initialized as an empty list in the parent SoftwareEngineer
class when the __init__
method is called. In child classes, such as FrontendDeveloper
, there is no need to create it again.
The use of self.skills.extend(...
) in child classes is correct because it simply extends the existing list of skills inherited from the parent class.
In other words, when you create an instance of the FrontendDeveloper
class, the skills
attribute will be a copy of the skills
list inherited from the parent class, but it will be unique for each instance.
class BackendDeveloper(SoftwareEngineer): | ||
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills.extend(["Python", "SQL", "Django"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check another comments
class AndroidDeveloper(SoftwareEngineer): | ||
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills.extend(["Java", "Android studio"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check another comments
No description provided.