Re: For next loops

2018-07-23 Thread Neil Cerutti
On 2018-07-23, no@none.invalid wrote: > 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 = "" Something like this is possible. "x", "y" and "result" can be

Re: For next loops

2018-07-23 Thread Brian Oney via Python-list
What if ply != com in the first (0th) iteration?  It's better to have an 'else:'-statement in your case, I suppose. -- https://mail.python.org/mailman/listinfo/python-list

Re: For next loops

2018-07-23 Thread Ben Finney
no@none.invalid writes: > never mind. Congratulations for working out the error. And thank you for returning to show the corrected code :-) -- \ “If you don't know what your program is supposed to do, you'd | `\ better not start writing it.” —Edsger W. Dijkstra | _o__)

For next loops

2018-07-23 Thread no
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

Re: For next loops

2018-07-22 Thread no
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@none.invalid wrote: >x = range (5) >y = range (5) >for ply in x: >for com in y: >