I have this dictionary and two functions.
marcador_game = {1: 0, 2: 0}
def punto_jugador(jugador):
marcador_game[jugador] += 1 # here I can use the dictonary without problems
if marcador_game[1] > marcador_game[2]:
return (1, 2)
else:
return (2, 1)
def calcular_puntaje(j_mayor, j_menor):
if marcador_game[j_mayor] > marcador_game[j_menor]: # here tell's me that variable is not declared
if marcador_game[j_mayor] == 4 and marcador_game[j_menor] < 4:
marcador_game = {1: 0, 2: 0}
marcador_sets[j_mayor] += 1
I can only use the dict in the second function if I use the dict as global before the if:
global marcador_game
Why I can alter the dict in the fist function but not evaluate it in the second?