Basic Python While loop compound conditional evaluation
Posted
by dbjohn
on Stack Overflow
See other posts from Stack Overflow
or by dbjohn
Published on 2010-06-09T13:58:49Z
Indexed on
2010/06/09
14:02 UTC
Read the original article
Hit count: 196
In Python IDLE Shell it seems I cannot use a compound conditional expression and a while loop. I tried it within brackets too.
k=0
m=0
while k<10 & m<10:
print k
k +=1
m+=1
If I write
while k<10:
print k
k+=1
This does work. Is there a way I could achieve the first block of code with the "and" operator. I have done it in Java. Do I just need to put together "if" statements to achieve the same functionality in Python?
© Stack Overflow or respective owner