For next loops

no at none.invalid no at none.invalid
Sun Jul 22 23:23:47 EDT 2018


never mind.
x = range (5)
y = range (5)
for ply in x:

    for com in y:
        if ply==com:
            result="Tie"

        print(ply,com,result)
        result = ""


On Sun, 22 Jul 2018 23:17:24 -0400, no at none.invalid wrote:

>x = range (5)
>y = range (5)
>for ply in x:
>    for com in y:
>        if ply==com:
>            result="Tie"
>        print(ply,com,result)
>
>Why is ply always equal to com?
>0 0 Tie
>0 1 Tie
>0 2 Tie
>0 3 Tie
>0 4 Tie
>1 0 Tie
>1 1 Tie
>1 2 Tie
>1 3 Tie
>1 4 Tie
>2 0 Tie
>2 1 Tie
>2 2 Tie
>2 3 Tie
>2 4 Tie
>3 0 Tie
>3 1 Tie
>3 2 Tie
>3 3 Tie
>3 4 Tie
>4 0 Tie
>4 1 Tie
>4 2 Tie
>4 3 Tie
>4 4 Tie


More information about the Python-list mailing list