I have been working through a fairly simple process to teach myself python and I am running into a problem with a comparison. Can anyone tell me where I am going wrong?
#!/usr/bin/env python class Team(object): code = "" opponents_debated=[] wins=0 losses=0 competitors=[] def __init__(self, code): self.code = code self.competitors.append(code) #self.school_teams.append(code) ####HERE'S THE LOGIC PROBLEM def havedebated(self, otherTeam): print (self.code, "compares ", otherTeam, "is in",self.competitors) if otherTeam in self.competitors: return 1 else: return 0 def giveCode(self): return self.code def debates(self,otherteam): self.competitors.append(otherteam) def make_team(code): team = Team(code) return team #MAIN Program# myTeamCodes = ["a", "aa", "b", "bb", "c", "cc", "d"] # Make teams myTeams = [] #list of teams for x in myTeamCodes: myteam = make_team(x) myTeams.append(myteam) for x in myTeams: x.print_team() for x in myTeams: for y in myTeams: affteam=x.giveCode() negteam=y.giveCode() print (affteam," vs. ",negteam) #have the two teams debated? if x.havedebated(negteam): print("they have debated...") continue else: print("DEBATE!") #NEVER HAPPENS! x.debates(negteam) thiscode=x.giveCode(); othercode=y.giveCode(); print(thiscode,"debates ",othercode) -- http://about.me/greggmartinson
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor