Warum wird current_score in der while-Schleife nicht aktualisiert? Beim erstmaligen Posten konnte die Antwort online nicht gefunden werden. Ich denke, es ist eine Scoping-Ausgabe halpVariable wird nicht in while-Schleife aktualisiert
def main():
player_1 = input("Player one: ")
player_1_score = 0
player_2 = input("Player two: ")
player_2_score = 0
num_sets = int(input("Points for a win: "))
current_score = "%s (%i : %i) %s" % (player_1, player_1_score, player_2_score, player_2)
while player_1_score <num_sets> player_2_score:
round = int(input("Who won this round? (type 1 for player one; type 2 for player two"))
if round == 1:
player_1_score += 1
else:
player_2_score += 1
print(current_score)
pass
if __name__ == '__main__':
main()
Wo sehen Sie es anweisen, zu aktualisieren. Beachten Sie, dass die Formatierung von Strings wie '...% ...' einmal ausgewertet wird ** ... –