Hi can someone tell me why this doesn’t work? It runs on forever and doesn’t end. When the a value reaches 10 it should exit the loop.
a=0
while a!=10:
for counter in range(11):
a+=counter
print a
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
abecomes10while it is still inside of theforloop (and gets larger than10when thewhileloop goes for a second run).Move your
printdown one level and you’ll see what I mean: