[PyGame] Error "Else expected" - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Game Development (https://python-forum.io/forum-11.html) +--- Thread: [PyGame] Error "Else expected" (/thread-25901.html) |
Error "Else expected" - aryagon - Apr-15-2020 Hello, I was coding a simple mastermind but I can't get rid of this "else expected" error at line 26. I have no if empty, and I don't see the problem. Thanks for your help! def verificationCode(code,proposition,ligneActive): bons=0 mauvais=0 for i,v in enumerate(proposition): if v==code[i]: bons+=1 proposition[i]="#" code[i]="*" for i,v in enumerate(proposition): if v in code: mauvais+=1 code[code.index(v)]="*" if mauvais > 0 : malplace = pygame.image.load("malplace.png").convert() fenetre.blit(malplace, (10,630-ligneActive*50)) mauvais-=1 elif mauvais> 0 : bienplace = pygame.image.load("bienplace.png").convert() fenetre.blit(bienplace, (10,630-ligneActive*50)) bons-=1 else: vide = pygame.image.load("vide.png").convert() fenetre.blit(vide, (10,630-ligneActive*50) ##error next line, it says expected else if mauvais > 0 : malplace = pygame.image.load("malplace.png").convert() fenetre.blit(malplace, (25,630-ligneActive*50)) mauvais-=1 elif bons > 0 : bienplace = pygame.image.load("bienplace.png").convert() fenetre.blit(bienplace, (25,630-ligneActive*50)) bons-=1 else : vide = pygame.image.load("vide.png").convert() fenetre.blit(vide, (25,630-ligneActive*50) if mauvais > 0 : malplace = pygame.image.load("malplace.png").convert() fenetre.blit(malplace, (10,615-ligneActive*50)) mauvais-=1 elif bons > 0 : bienplace = pygame.image.load("bienplace.png").convert() fenetre.blit(bienplace, (10,615-ligneActive*50)) bons-=1 else : vide = pygame.image.load("vide.png").convert() fenetre.blit(vide, (10,615-ligneActive*50) ##placement quatrieme pion if mauvais > 0 : malplace = pygame.image.load("malplace.png").convert() fenetre.blit(malplace, (25,615-ligneActive*50)) mauvais-=1 elif bons > 0 : bienplace = pygame.image.load("bienplace.png").convert() fenetre.blit(bienplace, (25,615-ligneActive*50)) bons-=1 else : vide = pygame.image.load("vide.png").convert() fenetre.blit(vide, (25,615-ligneActive*50) if bons = 4 : return True else : return False RE: Error "Else expected" - TomToad - Apr-15-2020 Often times, where the error is detected isn't on the line where the error occurs. Look carefully at the previous lines and see if there is an error. hint: count the parentheses |