Ich möchte eine Methode so definieren, dass eine Variable verändert wird, und wenn diese größer als 2 und größer als 5 andere Variablen ist, "mehrheit" ausgegeben wird.
Nach dreimaligem Aufrufen der Methode mit immer gleichem Parameter geschieht jedoch nichts, obwohl die Bedingung scheinbar erfüllt ist.
Was ist jetzt der Fehler?
Code: Alles auswählen
global votes1,votes2,votes3,votes4,votes5,votes6
votes1 = 0
votes2 = 0
votes3 = 0
votes4 = 0
votes5 = 0
votes6 = 0
def define_names(player1, player2, player3, player4, player5, player6):
global playerlist
playerlist = [player1, player2, player3, player4, player5, player6]
global playertupel
playertupel = (playerlist)
define_names("Mauritz","Luigi","Giuseppe","Giacomo","Moritz","Paolo")
vote_dictionary = {playertupel[0] : votes1, playertupel[1] : votes2,
playertupel[2] : votes3, playertupel[3] : votes4,
playertupel[4] : votes5, playertupel[5] : votes6}
class Villager:
def __init__(self, werewolf = False, alive = True, awake = True, name = "Default"):
self.werewolf = werewolf
self.alive = alive
self.awake = awake
self.name = name
#diese Methode:
def voting(self, vote):
if vote in playertupel:
print "Eine Stimme mehr für " + vote
vote_dictionary[vote] += 1
print (vote_dictionary[vote])
if (vote_dictionary[vote] == max(vote_dictionary)
and vote_dictionary[vote] > 2):
print "mehrheit"
elif vote not in playertupel:
print "Gib einen existierenden Spieler an!"
Mauritz = Villager()