jeudi 18 juin 2020

Python nesting elif,for

Is it possible to write a for inside elif? i have many elif statements and i want my last elif statement to have a for inside elif how to write nested elif in PYTHON

def victory(see,z):
if see[0]==see[1]==see[2]==z:
        print(z,"wins")
    elif see[3]==see[4]==see[5]==z:
        print(z,"wins")
    elif see[6]==see[7]==see[8]==z:
        print(z,"wins")
    elif see[0]==see[3]==see[6]==z:
        print(z,"wins")
    elif see[1]==see[4]==see[7]==z:
        print(z,"wins")
    elif see[2]==see[5]==see[8]==z:
        print(z,"wins")
    elif see[0]==see[4]==see[8]==z:
        print(z,"wins")
    elif see[2]==see[4]==see[6]==z:
        print(z,"wins")
    elif for blank in see if blank=="_" or"__"or"___":
            print("game not finished")

Aucun commentaire:

Enregistrer un commentaire