Try to search your question here, if you can't find : Ask Any Question Now ?

Python – Attribute Error – str' object has no attribute 'studentsinTeam'

HomeCategory: stackoverflowPython – Attribute Error – str' object has no attribute 'studentsinTeam'
Avatarcraig asked 5 days ago

I am trying to create a program where it allows the user to add existing students to an existing team. When I try to do this, it produces AttributeError: ‘str’ object has no attribute ‘studentsinTeam’.

class Student: 

  def __init__(self, student_name, form_class):
    self.student_name = student_name 
    self.form_class = form_class
    self.studentTeamlist = []

  def addtoTeam(self, team):
    if self.student_name not in team.studentsinTeam:
      team.studentsinTeam.append(self.student_name)
      self.studentTeamlist.append(team)

class Team: 


  def __init__(self, team, coach):
    self.team = team
    self.coach = coach
    self.studentsinTeam = []

class AddStudentToTeam: 

def pressed2(self):
    addName2 = self.getName2.get()
    joinTeam = self.getTeam.get()

    for s,t in itertools.product(allStudentlist, allTeamlist):
      if s.student_name == addName2 and t.team == joinTeam:
        if joinTeam not in s.studentTeamlist:
          s.addtoTeam(joinTeam) 
          messagebox.showinfo("Success", "Successful! ADDED")
        elif joinTeam in s.studentTeamlist:
          messagebox.showerror("Error", "Student Already in Team")


How do I resolve this error?

1 Answers
Best Answer
AvatarAmit answered 5 days ago
Your Answer

1 + 14 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com