Re: Appending question
Re: Appending question Yes, and that would add an empty list within a list, or an empty string into the list, but this would also make the function not do anything with the variable you pass to it. What ends up in self.skills, using that function, entirely depends on what you pass the function, if you put "add_new_skills("")" it would append that empty text string into self.skills, or if you put "add_new_skills([])" it would append the empty list into self.skills. URL: https://forum.audiogames.net/post/453073/#p453073 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Appending question
Re: Appending question @4 Magrib, with your version of code: def add_new_skills(self, skill): self.skills.append(skill)instead of (skill) variable can't we pass an empty list?i mean like this; self.skills.append([]) or an empty string like this, self.skills.append("") URL: https://forum.audiogames.net/post/452952/#p452952 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Appending question
Re: Appending question The purpose of that function i'm going to assume is to add a skill to a list of skills for that worker, but the given code is incorrect and won't work. When you pass a variable to a function, what its called internally is arbitrary. In that function add_new_skills(), the passed variable is called "name", except you try to add "skill" to self.skills, which doesn't exist and will cause an error. This means you either need to change the internal name of the function from "name" to "skill", or change what you append to self.skills, like so:def add_new_skills(self, name): self.skills.append(name)Or:def add_new_skills(self, skill): self.skills.append(skill) URL: https://forum.audiogames.net/post/452852/#p452852 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Appending question
Re: Appending question Ethin wrote:This will not compile/run. Change the skill item to name. Also, alter the name of the function -- it is misleading, because it only adds a signel skill, not multiple.u mean will i put self.name instead of skill?but skills placed inside self.skills isn't it? URL: https://forum.audiogames.net/post/452841/#p452841 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: Appending question
Re: Appending question This will not compile/run. Change the skill item to name. Also, alter the name of the function -- it is misleading, because it only adds a signel skill, not multiple. URL: https://forum.audiogames.net/post/452505/#p452505 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Appending question
Appending question Guys, there is a class with this function inside...def add_new_skills(self, name): self.skills.append(skill)Ok so, if You've realized there is a possible variable inside paranteses. i mean the skill word without s, what it's for, can you explain to me? i mean why not an empthy string instead with appending line.at first i thought it refers the "skill" variable on *for loop* below but, it doesn't sound reasonable to me.Full code.class worker: staff = [] def __init__(self, name): self.name = name self.skills = [] self.add_member() def new_member(self): self.staff.append(self.name) print("{} added to the staff.".format(self.name)) def view_staff(self): print("Member list") for member in self.members: print(member) def add_new_skills(self, name): self.skills.append(skill) def view_skills(self): print({}'s skills: ".format(self.name)) for skill in self.skills: print(skill) URL: https://forum.audiogames.net/post/452503/#p452503 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector