Ich brauche Hilfe für ein Python-Spiel, das ich gerade erstelle. Wenn der Code ausgeführt wird, bleibt er offen und tut nichts, nachdem er mehrmals umgelegt hat. Hier ist, was ich bisher:Python Heads and Tails
# Heads and Tails generator
# User how many times they wish to flip a coin and will recieve the results
CoinTosses = int(input("How many coins do you wish to flip: "))
Heads = 0
Tails = 0
CurrentCoinToss = 0
from random import randint
while CoinTosses != 0:
CurrentCoinToss == int(randint(1, 2))
if CurrentCoinToss == 1:
Heads += 1
CoinTosses -= 1
if CurrentCoinToss == 2:
Tails += 1
CoinTosses -= 1
print("During this round you recieved: ", Heads, " and", Tails, " Tails!")
input("Press the enter key to exit")
Was mit diesem ist falsch? Ich habe meinen Code studiert und nichts sollte falsch sein.
Sie haben eine extra '=' bekam. – TigerhawkT3
Und bitte vermeiden Sie PascalCase und verwenden Sie snake_case für Variablen. In [PEP 8] (https://www.python.org/dev/peps/pep-0008/) finden Sie einen Style Guide für Python Code – Francesco
CurrentCoinToss ist gleich 0, dann CurrentCoinToss == int (randint (1, 2)) vergleicht nur 2 Variablen (ohne es auszudrucken oder etwas mit dem Ergebnis zu tun) –