[Tutor] Why is it not working?
Alan Gauld
alan.gauld at btinternet.com
Thu Feb 5 02:03:34 CET 2015
On 05/02/15 00:12, Antonio Zagheni wrote:
> from Tkinter import *
...
> jogador = 1
> rodada = 1
> fim = False
Notice that fim is declared here as a global variable
> def analise():
> global jogador, rodada
But you do not include fim here
> print flag_botaoA1, flag_botaoA2, flag_botaoA3
> print flag_botaoB1, flag_botaoB2, flag_botaoB3
> print flag_botaoC1, flag_botaoC2, flag_botaoC3
> print jogador, rodada
> if rodada == 9:
> active_player.set('Game Over!')
> fim = True
So when you set fim here you are setting a local variable
only visible inside the analise() function.
You need to make fim global.
That's the only thing I can see although not speaking Portuguese
makes it harder to check the logic.
You have a lot of repetitive code there that could be
made much simpler. But that's a mail for another time.
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list